diff options
author | Denis Ovsienko <denis@ovsienko.info> | 2017-10-15 00:43:26 +0000 |
---|---|---|
committer | Denis Ovsienko <denis@ovsienko.info> | 2017-10-15 00:43:26 +0000 |
commit | f1f1c08af656c118cbcf99a40d868b757044ead5 (patch) | |
tree | 46ebe5be45e93be2e47a4a78c5df6493cabd5cc6 /pcap/compiler-tests.h | |
parent | c896b8a33427a00c28d78b48887898406d307de7 (diff) |
Address CLang "undefined defined" warnings.
Building tcpdump with CLang recently started to produce 9 warnings per
each .c file along the following lines:
In file included from ./print-pflog.c:39:
In file included from ./netdissect.h:75:
In file included from ../libpcap/pcap.h:43:
In file included from ../libpcap/pcap/pcap.h:72:
../libpcap/pcap/funcattrs.h:115:8: warning: macro expansion producing
'defined' has undefined behavior [-Wexpansion-to-defined]
|| PCAP_IS_AT_LEAST_SUNC_VERSION(5, 9) \
^
../libpcap/pcap/compiler-tests.h:89:3: note: expanded from macro
'PCAP_IS_AT_LEAST_SUNC_VERSION'
(defined(__SUNPRO_C) && \
^
Replace each involved 2-ary macro with one or more 0-ary macro(s) and
use those. This will require to add a new 0-ary macro for each new
required combination of major/minor version numbers of a particular
compiler, but this change makes tcpdump compile almost cleanly again.
Diffstat (limited to 'pcap/compiler-tests.h')
-rw-r--r-- | pcap/compiler-tests.h | 78 |
1 files changed, 66 insertions, 12 deletions
diff --git a/pcap/compiler-tests.h b/pcap/compiler-tests.h index 205cd7a6..03ef7b4a 100644 --- a/pcap/compiler-tests.h +++ b/pcap/compiler-tests.h @@ -59,10 +59,36 @@ * compiler that claims to be "just like GCC" of that version or a * later release. */ -#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \ - (defined(__GNUC__) && \ - (__GNUC__ > (major) || \ - (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))) + +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 3)) +#define PCAP_IS_AT_LEAST_GNUC_VERSION_2_3 1 +#else +#define PCAP_IS_AT_LEAST_GNUC_VERSION_2_3 0 +#endif + +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)) +#define PCAP_IS_AT_LEAST_GNUC_VERSION_2_5 1 +#else +#define PCAP_IS_AT_LEAST_GNUC_VERSION_2_5 0 +#endif + +#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +#define PCAP_IS_AT_LEAST_GNUC_VERSION_3_1 1 +#else +#define PCAP_IS_AT_LEAST_GNUC_VERSION_3_1 0 +#endif + +#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +#define PCAP_IS_AT_LEAST_GNUC_VERSION_3_4 1 +#else +#define PCAP_IS_AT_LEAST_GNUC_VERSION_3_4 0 +#endif + +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) +#define PCAP_IS_AT_LEAST_GNUC_VERSION_4_5 1 +#else +#define PCAP_IS_AT_LEAST_GNUC_VERSION_4_5 0 +#endif /* * Check wehether this is Sun C/SunPro C/Oracle Studio major.minor @@ -85,9 +111,24 @@ (((minor) >= 10) ? \ (((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \ (((major) << 8) | ((minor) << 4))) -#define PCAP_IS_AT_LEAST_SUNC_VERSION(major, minor) \ - (defined(__SUNPRO_C) && \ - (__SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD((major), (minor)))) + +#if defined(__SUNPRO_C) && __SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD(5, 5) +#define PCAP_IS_AT_LEAST_SUNC_VERSION_5_5 1 +#else +#define PCAP_IS_AT_LEAST_SUNC_VERSION_5_5 0 +#endif + +#if defined(__SUNPRO_C) && __SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD(5, 9) +#define PCAP_IS_AT_LEAST_SUNC_VERSION_5_9 1 +#else +#define PCAP_IS_AT_LEAST_SUNC_VERSION_5_9 0 +#endif + +#if defined(__SUNPRO_C) && __SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD(5, 13) +#define PCAP_IS_AT_LEAST_SUNC_VERSION_5_13 1 +#else +#define PCAP_IS_AT_LEAST_SUNC_VERSION_5_13 0 +#endif /* * Check wehether this is IBM XL C major.minor or a later release. @@ -95,8 +136,18 @@ * The version number in __xlC__ has the major version in the * upper 8 bits and the minor version in the lower 8 bits. */ -#define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ - (defined(__xlC__) && __xlC__ >= (((major) << 8) | (minor))) + +#if defined(__xlC__) && __xlC__ >= ((10 << 8) | 1) +#define PCAP_IS_AT_LEAST_XL_C_VERSION_10_1 1 +#else +#define PCAP_IS_AT_LEAST_XL_C_VERSION_10_1 0 +#endif + +#if defined(__xlC__) && __xlC__ >= ((12 << 8) | 0) +#define PCAP_IS_AT_LEAST_XL_C_VERSION_12_0 1 +#else +#define PCAP_IS_AT_LEAST_XL_C_VERSION_12_0 0 +#endif /* * Check wehether this is Sun C/SunPro C/Oracle Studio major.minor @@ -109,8 +160,11 @@ * (Strip off the A., remove the . between the major and minor version * number, and add two digits of patch.) */ -#define PCAP_IS_AT_LEAST_HP_C_VERSION(major, minor) \ - (defined(__HP_aCC) && \ - (__HP_aCC >= ((major)*10000 + (minor)*100))) + +#if defined(__HP_aCC) && (__HP_aCC >= (6*10000 + 10*100)) +#define PCAP_IS_AT_LEAST_HP_C_VERSION_6_10 1 +#else +#define PCAP_IS_AT_LEAST_HP_C_VERSION_6_10 0 +#endif #endif /* lib_pcap_funcattrs_h */ |