diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2025-01-16 20:27:36 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2025-01-16 20:35:09 +0100 |
commit | 9c881fa867f184e80293ee86974f2c0c0b5fb7a3 (patch) | |
tree | abae437c4a5f2c8713a575c4003c2c5a505dde96 /src/fundamental/macro-fundamental.h | |
parent | nss-systemd: work around -Werror=zero-as-null-pointer-constant issue with PTH... (diff) | |
download | systemd-9c881fa867f184e80293ee86974f2c0c0b5fb7a3.tar.xz systemd-9c881fa867f184e80293ee86974f2c0c0b5fb7a3.zip |
fundamental-macro: conditionalize several gcc warning pragmas
This fixes the following error:
In file included from ../src/basic/macro.h:13,
from ../src/basic/env-util.h:9,
from ../src/nss-systemd/nss-systemd.c:7:
../src/fundamental/macro-fundamental.h:61:9: error: option ‘-Wzero-as-null-pointer-constant’ is valid for C++/ObjC++ but not for C [-Werror=pragmas]
61 | _Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
| ^~~~~~~
../src/nss-systemd/nss-systemd.c:106:1: note: in expansion of macro ‘DISABLE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT’
106 | DISABLE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Diffstat (limited to '')
-rw-r--r-- | src/fundamental/macro-fundamental.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index 7bee2915e1..5eb31cd742 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -52,13 +52,23 @@ _Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic ignored \"-Wstringop-truncation\"") -#define DISABLE_WARNING_ZERO_LENGTH_BOUNDS \ +#if HAVE_WARNING_ZERO_LENGTH_BOUNDS +# define DISABLE_WARNING_ZERO_LENGTH_BOUNDS \ _Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic ignored \"-Wzero-length-bounds\"") +#else +# define DISABLE_WARNING_ZERO_LENGTH_BOUNDS \ + _Pragma("GCC diagnostic push") +#endif -#define DISABLE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT \ +#if HAVE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT +# define DISABLE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT \ _Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"") +#else +# define DISABLE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT \ + _Pragma("GCC diagnostic push") +#endif #define REENABLE_WARNING \ _Pragma("GCC diagnostic pop") |