Do not use diagnostic pragma when GCC version is lower than 4.6.0
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 4 Jul 2019 18:31:16 +0000 (14:31 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 4 Jul 2019 21:53:58 +0000 (17:53 -0400)
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 <jonathan.rajotte-julien@efficios.com>
Change-Id: Ie6e4e8bd631f7aab1435fece929621c9a11990e4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1630
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/compat/bitfield.h

index 5e5a046f033d600ce67821c8f8ae4062b3ea7ef2..e2f2c128ed79ad5048099ef042928b2743b6c5c4 100644 (file)
 /*
  * _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")
 
This page took 0.025672 seconds and 4 git commands to generate.