Search code examples
c++clangllvmgdcm

warning: disabled expansion of recursive macro


I am currently building the GDCM project using MacOSX default compiler: clang. This compiler trigger a warning in its own header (see 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.

This is either a clear bug in llvm header (which I find hard to believe), or I am missing something about the use of setjmp in C++98.


Solution

  • It's neither. It's not a bug in an LLVM header, it's not that you're missing something about the use of setjmp, it's that you've enabled a warning that happens to also trigger on perfectly valid code. Most warnings do. That's why they're warnings rather than errors. This particular warning happens to mostly trigger on valid code. That's why it's not enabled by default, not even included in -Wall, and not even included in -Wextra. Yet you enabled it anyway. That's fine, but then you should be prepared to deal with the results.