clang warning -Wexpansion-to-defined
Hello,
I had a look at clang -Wexpansion-to-defined warning [1] which is part of -Wall in recent version of clang. It is related to the fact that #defined() pre-processor directive is used outside of a #if directive [2]
#if defined( OTB_DEBUG ) // no warning
#define IS_OTB_DEBUG defined( OTB_DEBUG ) #if IS_OTB_DEBUG // warning
Fix :
#ifdef OTB_DEBUG #define IS_OTB_DEBUG 1 #else #define IS_OTB_DEBUG 0 #endif
#if IS_OTB_DEBUG // no warning
In OTB, we use several complex #define USE_FOO directives to enable easy enabling/disabling of various options based on various switches.
There are 2 options :
- Ignore this warning (my preferred)
- Fixed all macro definitions as quoted above.
[1] https://dash.orfeo-toolbox.org/viewBuildError.php?type=1&buildid=315002
[2] https://gcc.gnu.org/ml/gcc-patches/2016-08/msg00738.html