include: Fix -Wundef warnings in ansidecl.h
This quashes -Wundef warnings in ansidecl.h when compiled in C or C++. In C, __cpp_constexpr and __cplusplus aren't defined so we evaluate them to 0; conversely, __STDC_VERSION__ is not defined in C++. This has caused grief when -Wundef is used with -Werror. I've also tested -traditional-cpp. include/ChangeLog: * ansidecl.h: Check if __cplusplus is defined before checking the value of __cpp_constexpr and __cplusplus. Don't check __STDC_VERSION__ in C++.
This commit is contained in:
parent
ead235f601
commit
34dbb5f346
|
@ -79,7 +79,7 @@ So instead we use the macro below and test it against specific values. */
|
||||||
/* inline requires special treatment; it's in C99, and GCC >=2.7 supports
|
/* inline requires special treatment; it's in C99, and GCC >=2.7 supports
|
||||||
it too, but it's not in C89. */
|
it too, but it's not in C89. */
|
||||||
#undef inline
|
#undef inline
|
||||||
#if __STDC_VERSION__ >= 199901L || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__))
|
#if (!defined(__cplusplus) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__))
|
||||||
/* it's a keyword */
|
/* it's a keyword */
|
||||||
#else
|
#else
|
||||||
# if GCC_VERSION >= 2007
|
# if GCC_VERSION >= 2007
|
||||||
|
@ -356,7 +356,7 @@ So instead we use the macro below and test it against specific values. */
|
||||||
#define ENUM_BITFIELD(TYPE) unsigned int
|
#define ENUM_BITFIELD(TYPE) unsigned int
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cpp_constexpr >= 200704
|
#if defined(__cplusplus) && __cpp_constexpr >= 200704
|
||||||
#define CONSTEXPR constexpr
|
#define CONSTEXPR constexpr
|
||||||
#else
|
#else
|
||||||
#define CONSTEXPR
|
#define CONSTEXPR
|
||||||
|
@ -419,7 +419,7 @@ So instead we use the macro below and test it against specific values. */
|
||||||
|
|
||||||
so that most attempts at copy are caught at compile-time. */
|
so that most attempts at copy are caught at compile-time. */
|
||||||
|
|
||||||
#if __cplusplus >= 201103
|
#if defined(__cplusplus) && __cplusplus >= 201103
|
||||||
#define DISABLE_COPY_AND_ASSIGN(TYPE) \
|
#define DISABLE_COPY_AND_ASSIGN(TYPE) \
|
||||||
TYPE (const TYPE&) = delete; \
|
TYPE (const TYPE&) = delete; \
|
||||||
void operator= (const TYPE &) = delete
|
void operator= (const TYPE &) = delete
|
||||||
|
|
Loading…
Reference in New Issue