手臂上的qt3:无法绑定打包字段

qt3 on arm: cannot bind packed field

我正在使用一个使用 qt3 的软件。它在 x86-linux 系统上运行良好。当我试图将它移植到 Raspberry Pi 2 时,我遇到了一个奇怪的编译器错误。 Google 无法帮助我,我尝试的一切都失败了。

错误是:

cannot bind packed field '((QChar*)this)->QChar::ucs' to 'ushort&{aka short unsigned int&}'

指的是qstring.h

后面的部分
class Q_EXPORT QChar {
    ...
#ifdef Q_NO_PACKED_REFERENCE
    ushort &unicode() { return *(&ucs); }
#else
    ushort &unicode() { return ucs; } // Throws error
#endif
    ...
}

当然我已经尝试定义 Q_NO_PACKED_REFERENCE 只是将错误移动到上面的行。我还尝试明确定义架构、float abi 和 cpu.

这是我的环境:

如果你想知道为什么我使用 qt3 和一个旧的 gcc,那是因为我们想让我们的源代码与我们使用的一些旧系统兼容。

我的问题是: 此错误的原因是什么,我该如何解决?(最好在不更改 qt3 头文件的情况下进行修复。)

那个错误很奇怪。我找到的解决方案甚至更奇怪。

似乎是 https://download.qt.io/archive/qt/3/ contain different header files than the debian packages from https://launchpad.net/ubuntu/precise/armhf.

的 qt3 安装

从 debian 软件包安装 qt3 而不是从 qt 页面编译源代码后,我的代码编译正常。

我查看了两个 header 文件,导致错误的行现在包含一个额外的转换。

来自 qt.io

class Q_EXPORT QChar {
    ...
#ifdef Q_NO_PACKED_REFERENCE
    ushort &unicode() { return *(&ucs); }
#else
    ushort &unicode() { return ucs; } // Throws error
#endif
    ...
}

从启动板

class Q_EXPORT QChar {
    ...
#ifdef Q_NO_PACKED_REFERENCE
    ushort &unicode() { return *((ushort*)&ucs); }
#else
    ushort &unicode() { return ucs; } // Throws error
#endif
    ...
}

两组header之间的差异似乎更大。如果其他人对 qt header 文件有任何问题,也可能是这些差异。