PDA

View Full Version : qFromBigEndian(...) not found??



maverick_pol
12th February 2009, 13:17
Hi,

I have trivial question:
I can use all the functions from the QtGlobal, but when I try to use one of these


T qFromBigEndian ( const uchar * src )
T qFromBigEndian ( T src )
T qFromLittleEndian ( const uchar * src )
T qFromLittleEndian ( T src )


I get an error pointing that the functions' declarations cannot be found( as I haven't included the header).

I have checked it many times I can use other functions and features from this QtGlobal, but not the mentioned functions.

{ADDED}
I have checked the global.h and I have no declaration of the qFromBigEndian(...) etc.
Where are these functions declared then?

Thanks

jpn
12th February 2009, 13:20
Hi, try including <qendian.h> or <QtEndian>.

talk2amulya
12th February 2009, 13:42
its in <qendian.h>

maverick_pol
12th February 2009, 13:54
yes, I have found that, but when I include the
qendian.h I get a "undefined ref to qFromBigEndian(...)" while linking.



/usr/local/Trolltech/Qt-4.4.3/include/QtCore/qendian.h:327: undefined reference to `unsigned char const* qbswap<unsigned char const*>(unsigned char const*)'
collect2: ld returned 1 exit status

talk2amulya
12th February 2009, 13:59
well, this function is inside Corelib in source..so it must be in QtCore

maverick_pol
12th February 2009, 14:05
I have included :


#include <QtCore>
#include <endian.h>


still "underfined ref".

spirit
12th February 2009, 14:23
use #include <QtGlobal>

maverick_pol
12th February 2009, 14:24
Done that already.



#include <QtGlobal>
#include <QtCore>
#include <qtendian.h>

talk2amulya
12th February 2009, 15:24
r u sure u hv lib file of qtcore added in the project settings?

Tristan
21st April 2009, 10:57
For sure the user had found a solution or a workaround now.

For the others, coming here by google's or yahoo or whatever search engine you like, the solution reside in 'data type'iing, because C++ class templates are a bit touchy about that.

For example:


qFromBigEndian(*(quint16 *)(socket->read( 2 ).data())) : compile well under Ubuntu 8.x/Qt 4.5 :cool:

qFromBigEndian(*(socket->read( 2 ).data())) : DOES NOT compile well under Ubuntu 8.x/Qt 4.5 :(


Maybe because the compiler doesn't know how to choose between QByteArray methods
char * data ()
const char * data () const