枚举成员的gcc:__ attribute__

时间:2015-04-22 05:34:10

标签: c gcc enums clang

GNU gcc和clang gcc无法就此代码是否有效达成一致。 哪一个有错误?

用clang:

$ /usr/bin/gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix

$ echo 'enum {a = 1, b __attribute__((availability(macosx,introduced=10.10))) = 1};' | /usr/bin/gcc -c -xc -
(no output, it works)

使用GNU gcc:

$ gcc --version
gcc (GCC) 4.9.2

$ echo 'enum {a = 1, b __attribute__((availability(macosx,introduced=10.10))) = 1};' | gcc -c -xc -
<stdin>:1:16: error: expected ',' or '}' before '__attribute__'

对于那些必须知道世界上为什么我可能会关心的人来说,有upstream bug in sagemath


看起来这显然是一个clang扩展,所以也许错误在于谁将它放在C头中。

http://clang.llvm.org/docs/LanguageExtensions.html#attributes-on-enumerators

0 个答案:

没有答案