From 193015bb595d8a5500e658a5e0be7370de5d33e3 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 4 Jul 2019 14:31:16 -0400 Subject: [PATCH] Do not use diagnostic pragma when GCC version is lower than 4.6.0 Building on a SLES11 SP4. gcc (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973 bison (GNU Bison) 2.4 autoconf (GNU Autoconf) 2.69 automake (GNU automake) 1.15 GNU Make 3.81 The same would probably happen if using RHEL6 and its default compiler since it uses GCC 4.4 [1]. The README suggest that we support GCC > 3.2. Officially the diagnostic pragma are supported starting in 4.6. [2] But they were present before 4.6 with limitation. Error encountered: integer.c: In function 'ctf_integer_read': integer.c:271: error: #pragma GCC diagnostic not allowed inside functions integer.c:271: error: #pragma GCC diagnostic not allowed inside functions integer.c:271: error: #pragma GCC diagnostic not allowed inside functions integer.c:276: error: #pragma GCC diagnostic not allowed inside functions integer.c:276: error: #pragma GCC diagnostic not allowed inside functions integer.c:276: error: #pragma GCC diagnostic not allowed inside functions integer.c:282: error: #pragma GCC diagnostic not allowed inside functions integer.c:282: error: #pragma GCC diagnostic not allowed inside functions integer.c:282: error: #pragma GCC diagnostic not allowed inside functions integer.c:287: error: #pragma GCC diagnostic not allowed inside functions integer.c:287: error: #pragma GCC diagnostic not allowed inside functions integer.c:287: error: #pragma GCC diagnostic not allowed inside functions [1] https://access.redhat.com/solutions/19458 [2] https://gcc.gnu.org/gcc-4.6/changes.html Signed-off-by: Jonathan Rajotte Change-Id: Ie6e4e8bd631f7aab1435fece929621c9a11990e4 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1630 Reviewed-by: Philippe Proulx --- src/compat/bitfield.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compat/bitfield.h b/src/compat/bitfield.h index 5e5a046f..e2f2c128 100644 --- a/src/compat/bitfield.h +++ b/src/compat/bitfield.h @@ -44,8 +44,10 @@ /* * _bt_is_signed_type() willingly generates comparison of unsigned * expression < 0, which is always false. Silence compiler warnings. + * GCC versions lower than 4.6.0 do not accept diagnostic pragma inside + * functions. */ -#ifdef __GNUC__ +#if defined(__GNUC__) && (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600 # define _BT_DIAG_PUSH _Pragma("GCC diagnostic push") # define _BT_DIAG_POP _Pragma("GCC diagnostic pop") -- 2.34.1