fix: allocating C++ compound literal on heap with Clang
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 6 Dec 2021 20:05:59 +0000 (15:05 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 9 Dec 2021 16:26:56 +0000 (11:26 -0500)
Exclude Clang from the GCC version macro check for <= 4.8 since most
versions of Clang seem to identify themselves as GCC 4.2 which in this
case forces the allocation of C++ compound literals on the heap which
is only supported starting with Clang >= 6.0.

The macro was also broken for GCC <= 4.8 in C mode, add missing
parentheses around the 'or' statement to properly distinguish between C
and C++.

Also document the minimal supported version of Clang 4.0 to build C++
probe providers.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I62eea00381b7dc5958a09b13044ad9e7f7caf2ab

README.md
include/lttng/ust-compiler.h

index e4fb9f2ddae6d3431cf935ee4965b0282242cb73..a101048622e42778d9c4e233e21a52fa3b3f6c65 100644 (file)
--- a/README.md
+++ b/README.md
@@ -194,7 +194,7 @@ human-readable text log.
 
 Since LTTng-UST 2.3, both tracepoints and tracepoint providers can be
 compiled in C++. To compile tracepoint probes in C++, you need
-G++ >= 4.7 or Clang. The C++ compilers need to support C++11.
+G++ >= 4.7 or Clang >= 4.0. The C++ compilers need to support C++11.
 
 
 Contact
index 674b519cd11991ee4a04b42abdb081e86d2d7843..eb201bdc93c791f142d2cbc0aa7a86fd90d2472d 100644 (file)
@@ -32,8 +32,8 @@
  * g++ 4.8 and prior do not support C99 compound literals. Therefore,
  * force allocating those on the heap with these C++ compilers.
  */
-#if defined (__cplusplus) && defined (__GNUC__) && \
-       (__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ <= 8))
+#if defined (__cplusplus) && !defined (__clang__) && defined (__GNUC__) && \
+       ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ <= 8)))
 # ifndef LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP
 #  define LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP
 # endif
This page took 0.025391 seconds and 4 git commands to generate.