警告:禁用递归宏的扩展

时间:2016-01-10 10:35:26

标签: c++ clang llvm gdcm

我目前正在使用GDCM默认编译器构建MacOSX项目:clang。此编译器在其自己的标头中触发警告(请参阅ref):

In file included from /Users/builder/external/GDCM/Source/MediaStorageAndFileFormat/gdcmJPEG12Codec.cxx:21:
/Users/builder/external/GDCM/Source/MediaStorageAndFileFormat/gdcmJPEGBITSCodec.cxx:336:9: warning: disabled expansion of recursive macro [-Wdisabled-macro-expansion]
    if (setjmp(jerr.setjmp_buffer))
        ^
/Users/builder/llvm/llvm-rel-install/bin/../include/c++/v1/setjmp.h:40:21: note: expanded from macro 'setjmp'
#define setjmp(env) setjmp(env)
                    ^
In file included from /Users/builder/external/GDCM/Source/MediaStorageAndFileFormat/gdcmJPEG12Codec.cxx:21:
/Users/builder/external/GDCM/Source/MediaStorageAndFileFormat/gdcmJPEGBITSCodec.cxx:724:9: warning: disabled expansion of recursive macro [-Wdisabled-macro-expansion]
    if (setjmp(jerr.setjmp_buffer))
        ^
/Users/builder/llvm/llvm-rel-install/bin/../include/c++/v1/setjmp.h:40:21: note: expanded from macro 'setjmp'
#define setjmp(env) setjmp(env)
                    ^
2 warnings generated.

这可能是llvm标题中的一个明显错误(我很难相信),或者我遗漏了setjmp中使用C++98的错误。

1 个答案:

答案 0 :(得分:6)

它既不是。这不是LLVM标头中的错误,并不是因为您错过了setjmp的使用,而是您启用了一个警告,该警告也会触发完全有效的代码。大多数警告都有。这就是为什么他们是警告而不是错误。此特定警告主要触发有效代码。这就是默认情况下未启用的原因,甚至不包括在-Wall中,甚至不包含在-Wextra中。然而你无论如何都启用了它。那很好,但是你应该准备好处理结果。

相关问题