I'm working with an software using qt3. It works fine un x86-linux systems. When i tried to port it to Raspberry Pi 2 i got a weird compiler error. Google wasn't able to help me and everything i tried failed.
The error is:
cannot bind packed field '((QChar*)this)->QChar::ucs' to 'ushort&{aka short unsigned int&}'
which is refering to the following part of qstring.h
class Q_EXPORT QChar {
...
#ifdef Q_NO_PACKED_REFERENCE
ushort &unicode() { return *(&ucs); }
#else
ushort &unicode() { return ucs; } // Throws error
#endif
...
}
Of course i already tried to define Q_NO_PACKED_REFERENCE
which just moves the error to the line above. I also tried to explicitely define the architecture, float abi and cpu.
Here is my environment:
If you wonder why i use qt3 and an old gcc, it's because we want to keep our source code compatible with some older systems we have in use.
My question is: What is the reason for this error and how can i fix it? (Preferably fixing without changing the qt3 header files.)
That error is weird. The solution i found is even weirder.
It seems the qt3 installations from https://download.qt.io/archive/qt/3/ contain different header files than the debian packages from https://launchpad.net/ubuntu/precise/armhf.
After installing qt3 from the debian packages instead of compiling the source from the qt page my code compiled fine.
I looked at both header files and the line causing the error now contains an additional cast.
From qt.io
class Q_EXPORT QChar {
...
#ifdef Q_NO_PACKED_REFERENCE
ushort &unicode() { return *(&ucs); }
#else
ushort &unicode() { return ucs; } // Throws error
#endif
...
}
From launchpad
class Q_EXPORT QChar {
...
#ifdef Q_NO_PACKED_REFERENCE
ushort &unicode() { return *((ushort*)&ucs); }
#else
ushort &unicode() { return ucs; } // Throws error
#endif
...
}
There seem to be even more differences between both sets of headers. If someone else has any problems regarding qt header files it also might be to these differences.