On 12/15/2017 12:28 AM, Bruno Haible wrote: Hi Bruno, >>> Or through an in-file pragma that specifically documents that we are >>> intentionally ignoring the warning. >> >> I vote for this. > > Does this patch eliminate the warning? > > I couldn't reproduce the issue with clang 3.9.1 on Linux, therefore I have > to ask you to test it.
It works, but... ;-)
Your patch disables that warning for the whole file. IMO, we should keep
the scope of the #pragma as narrow as possible.
We could have a pragma.h include file with the following C99 code (I
leave the clang and gcc version checks to you):
#define STRINGIFY(a) #a
#if defined __clang__
# define NOWARN(a) _Pragma( STRINGIFY( clang diagnostic ignored a ) )
# define NOWARN_PUSH(a) \
_Pragma( STRINGIFY( clang diagnostic push ) ) \
_Pragma( STRINGIFY( clang diagnostic ignored a ) )
# define NOWARN_POP _Pragma( STRINGIFY( gcc diagnostic pop ) )
#elif defined __GNUC__
# define NOWARN(a) _Pragma( STRINGIFY( gcc diagnostic ignored a ) )
# define NOWARN_PUSH(a) \
_Pragma( STRINGIFY( gcc diagnostic push ) ) \
_Pragma( STRINGIFY( gcc diagnostic ignored a ) )
# define NOWARN_POP _Pragma( STRINGIFY( gcc diagnostic pop ) )
#else
# define NOWARN
# define NOWARN_PUSH
# define NOWARN_POP
#endif
Now we could include that file where needed and make use of the defines like
NOWARN("-Wconditional-uninitialized")
or to narrow the scope
NOWARN_PUSH("-Wconditional-uninitialized")
... code ...
NOWARN_POP
WDYT ?
Regards, Tim
signature.asc
Description: OpenPGP digital signature
