在CentOS 5.9上编译时[gcc version 4.1.2 20080704 (Red Hat 4.1.2-54)
]。我的应用程序无法编译,并出现以下错误:
/opt/qt64/4.7.3/include/QtCore/qendian.h: In function ‘T qbswap(T) [with T = long long unsigned int]’:
/opt/qt64/4.7.3/include/QtCore/qendian.h:278: error: ‘bswap_64’ was not declared in this scope
/opt/qt64/4.7.3/include/QtCore/qendian.h: In function ‘T qbswap(T) [with T = unsigned int]’:
/opt/qt64/4.7.3/include/QtCore/qendian.h:282: error: ‘bswap_32’ was not declared in this scope
/opt/qt64/4.7.3/include/QtCore/qendian.h: In function ‘T qbswap(T) [with T = short unsigned int]’:
/opt/qt64/4.7.3/include/QtCore/qendian.h:286: error: ‘bswap_16’ was not declared in this scope
我认为Qt 4.7.3没什么问题,因为代码可以在MSVC2010和Fedora 9 [
gcc version 4.3.0 20080428 (Red Hat 4.3.0-8) (GCC)
]上正确编译,并且都可以针对Qt 4.7.3进行编译。我的问题是,有没有一种方法可以让GCC告诉我以下任何或所有信息:出现此错误之前代码中的最后一位,或者导致该编译器错误的完整代码跟踪,或者由我找出其他方法出如何解决我的代码?
最佳答案
最终,解决该问题的方法是,包含路径中的文件较早存在一个名为byteswap.h
的文件,该文件被包含在byteswap.h
的stdlib版本之前。由于该文件不包含bswap_64
,bswap_32
或bswap_16
的定义,因此生成了编译器错误。
解决方法是将第三方库中的byteswap.h
重命名为另一个不冲突的名称。
关于compiler-errors - 编译器错误堆栈跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17734832/