0

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:

  • CPU: ARMv7
  • OS: Ubuntu 16.04
  • Compiler: gcc/g++ 4.8.5 (Ubuntu/Linaro 4.8.5-4ubuntu2)
  • Qt Version: 3.3.8b from here (tried with x11 and embedded)

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.)

5
  • Possible duplicate of Why are non-const references to bitfields prohibited? Commented Jan 16, 2018 at 9:52
  • See also redhat.com/archives/fedora-arm/2009-June/msg00004.html about someone else who moved to ARM and found this Commented Jan 16, 2018 at 9:53
  • @underscore_d thanks, but i already found that. unfortunately the soluting found there doesn't work for me. Commented Jan 16, 2018 at 10:09
  • Then you could include in your post what you already tried and didn't work, so people don't waste time repeating it. Commented Jan 16, 2018 at 10:21
  • "qt3" is too wide. What version of Qt gave you this problem? What version fixed it? Commented Jan 16, 2018 at 11:55

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Well, what versions are they both? There will of course be differences if one is older than the other. The code here looks very hacky and implementation-defined (and that's me being generous), so it might be that they have to constantly update their hacks to fool compilers into doing what they want.
@underscore_d acording to the file name both headers should beling to version 3.3.8b. But yes, it really seems to be implementation defined. The behavior of this code changes with the target platform after all.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.