【问题标题】:Compiler error stack trace编译器错误堆栈跟踪
【发布时间】:2013-07-18 22:11:53
【问题描述】:

在 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 告诉我以下任何或所有信息:在我的代码中出现此错误之前的最后一个位置或导致此编译器错误的完整代码跟踪或其他一些让我弄清楚如何修复我的代码的方法?

【问题讨论】:

  • CentOS 可能没有这些bswap 函数,或者它们位于不同的标头中。你检查了吗?
  • 不,我没有。我该如何检查?
  • grep -R bswap /usr/include/*
  • 好像在多个地方定义/usr/include/asm-i386/byteorder.h /usr/include/asm-x86_64/byteorder.h /usr/include/bits/byteswap.h /usr/include/byteswap.h /usr/include/mtd/jffs2-user.h /usr/include/netinet/in.h
  • 好的,很酷。那么qendian.h 在其他地方寻找他们吗?

标签: compiler-errors g++


【解决方案1】:

最终,该问题的解决方案是在包含路径的前面有一个名为 byteswap.h 的文件,并且该文件被包含在 byteswap.h 的 stdlib 版本之前。因为该文件不包含bswap_64bswap_32bswap_16 的定义,所以生成了编译器错误。

修复方法是将第 3 方库中的 byteswap.h 重命名为另一个不冲突的名称。

【讨论】:

    猜你喜欢
    • 2018-09-19
    • 1970-01-01
    • 1970-01-01
    • 2012-07-18
    • 2016-06-21
    • 2017-05-19
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多