From 8481f7a0ad3a050ebc8fd665fec6abd76a84e606 Mon Sep 17 00:00:00 2001 From: Zifei Tong Date: Tue, 18 Jun 2013 09:48:21 -0400 Subject: [PATCH] Fix: Check C++ designated initializers support before compiling 'hello.cxx' test Tested on a Ububtu system with g++ 4.6, g++ 4.7 and clang++. Fixes #557 Signed-off-by: Zifei Tong Signed-off-by: Mathieu Desnoyers --- README | 3 ++- configure.ac | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README b/README index 1f6b9d2c..a2ff00bc 100644 --- a/README +++ b/README @@ -111,7 +111,8 @@ USAGE: - Enable instrumentation and control tracing with the "lttng" command from lttng-tools. See lttng-tools doc/quickstart.txt. - Note for C++ support: since LTTng-UST 2.3, both tracepoints and - tracepoint probes can be compiled with g++. + tracepoint probes can be compiled in C++. To compile tracepoint probes + in C++, you need g++ >= 4.7 or Clang. ENVIRONMENT VARIABLES: diff --git a/configure.ac b/configure.ac index 802ccaa5..716f22d6 100644 --- a/configure.ac +++ b/configure.ac @@ -83,8 +83,21 @@ AC_CACHE_CHECK([whether the C++ compiler works], [rw_cv_prog_cxx_works], [AC_LANG_PUSH([C++]) AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], - [rw_cv_prog_cxx_works=yes], + [check_cxx_designated_initializers=yes], [rw_cv_prog_cxx_works=no]) + if test "$check_cxx_designated_initializers" = "yes"; then + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ + struct foo { int a; int b; }; + void fct(void) + { + struct foo f = { .a = 0, .b = 1 }; + } + ]])],[ + rw_cv_prog_cxx_works=yes + ],[ + rw_cv_prog_cxx_works=no + ]) + fi AC_LANG_POP([C++])]) AM_CONDITIONAL([CXX_WORKS], [test "x$rw_cv_prog_cxx_works" = "xyes"]) -- 2.34.1