Menu

error C2664 construct a binary XmlRpcValue

Help
Tom McHale
2009-12-29
2013-04-24
  • Tom McHale

    Tom McHale - 2009-12-29

    When trying to compile this code snippet:

    void *pData = new char(length);
    infile.read(pData, length);
    XmlRpcValue data((void*) pData,(int) length);

    I get the following compiler error in VS 2008:

    1>c:\ism\isecureme\xmlrpc++0.7_vs2008\test\sendjpegtest\sendjpegtest.cpp(40) : error C2664: 'std::basic_istream<_Elem,_Traits>::read' : cannot convert parameter 1 from 'void *' to 'char *'
    1>        with
    1>        [
    1>            _Elem=char,
    1>            _Traits=std::char_traits<char>
    1>        ]
    1>        Conversion from 'void*' to pointer to non-'void' requires an explicit cast

    This confuses me as I see the following constructor in XmlRpcValue.h:

        XmlRpcValue(void* value, int nBytes)  : _type(TypeBase64)
        {
          _value.asBinary = new BinaryData((char*)value, ((char*)value)+nBytes);
        }

    So what gives? Why won't the compiler use this constructor?

    Thx,
    Tom

     
  • Tom McHale

    Tom McHale - 2009-12-30

    To clarify about the above… What I am trying to do is pass some base64 encoded binary data from a client to a server. (The sample code in the project has a client retrieving from a server.) Also, if in an XmlRpcValue method you do this:;

    value.asBinary = new BinaryData((char*)value, ((char*)value)+nBytes);
    }

    you get a runtime error "unhadled exception at 0x…. … .std::bad_alloc at memory location 0x…..

     
  • quique123

    quique123 - 2010-01-18

    Originally, XmlRpc++ was created with VC++ 6.0, and this "error" was hidden by the compiler. Please, check the help files from VS 2008 about the compiler error C2664 for a complete explanation. Unfortunatelly, I use XmlRpc++ still in the VC++ 6.0 environment, and I can not test it.

    Quique

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.