c++ - compile error using qFromBigEndian -


i'm trying use qfrombigendian read 32-bit int byte stream received on udp socket.

void processdata(uchar *data) {   qint32 addr;   addr = qfrombigendian(data); } 

compiling gives following error: error: invalid conversion 'uchar*' 'qint32'

the qt documentation says:

t qfrombigendian ( const uchar * src )

reads big-endian number memory location src , returns number in host byte order representation. note: template type t can either qint16, qint32 or qint64.

obviously i'm doing bit silly , hanging head in shame. can please explain obvious mistake?

note qfrombigendian(const uchar *src) function template.

you're missing template parameter, use

addr = qfrombigendian<qint32>(data); 

instead, , things work expected.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -