【问题标题】:gcc 4.9 error on #define#define 上的 gcc 4.9 错误
【发布时间】:2014-04-11 23:18:11
【问题描述】:

下面一行

#  define always_inline __attribute__((always_inline))

被包含(来自另一个包含的文件)并被 gcc 4.9 抱怨:

inc/compiler.h:98:40: error: '__always_inline__' was not declared in this scope
 #  define always_inline __attribute__((always_inline))
                                        ^

奇怪的是,相同的头文件 (compiler.h) 包含在另一个编译成功的源文件中。有任何想法吗? 编辑:我只是确保always_inline 没有预先#defined。仅供参考:

> g++ -v
Using built-in specs.
COLLECT_GCC=/opt/local/bin/g++-mp-4.9
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin13/4.9.0/lto-wrapper
Target: x86_64-apple-darwin13
Configured with: /opt/local/var/macports/build/_opt_mports_dports_lang_gcc49/gcc49/work/gcc-4.9-20140406/configure --prefix=/opt/local --build=x86_64-apple-darwin13 --enable-languages=c,c++,objc,obj-c++,fortran,java --libdir=/opt/local/lib/gcc49 --includedir=/opt/local/include/gcc49 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.9 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.9 --with-gxx-include-dir=/opt/local/include/gcc49/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --disable-cloog-version-check --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts gcc49 4.9-20140406_0'
Thread model: posix
gcc version 4.9.0 20140406 (experimental) (MacPorts gcc49 4.9-20140406_0) 

【问题讨论】:

  • 您在定义宏的行上收到了错误消息?
  • 如果你编译一个只包含那一行的foo.c 文件会发生什么?那条线上可能有一些有趣的角色吗?上一行的尾部反斜杠?
  • @KeithThompson 正如我所说:以前成功的编译中包含相同的标头...
  • 是的,但值得一试。
  • 它是如何使用的?您的文件的gcc -E 是否正确(预期)替换了您的宏? gcc 永远不应该以这种方式遵守宏,因为它只是一个宏。

标签: c++ compiler-errors c-preprocessor gcc4.9


【解决方案1】:

编译是说符号__always_inline__ 没有定义,你正在定义符号always_inline。 我的 compiler.h (arm\atmel studio) 定义为#define __always_inline inline __attribute__((__always_inline__))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多