I've updated the patch addressing the problems mentioned earlier. > Going forward, I think checking for the designated initializer feature > via a small C++ testfile is more in line with the Autoconf philosophy.
> Moreover, the documentation and patches should take LLVM into account. Tested on a Ububtu system with g++ 4.6, g++ 4.7 and clang++. Fix: Check C++ designated initializers support before compiling 'hello.cxx' test Fixes #557 Signed-off-by: Zifei Tong <[email protected]> --- README | 3 ++- configure.ac | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README b/README index 1f6b9d2..a2ff00b 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 802ccaa..0bc7992 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"]) -- 1.8.3.1 On 6/16/13, Mathieu Desnoyers <[email protected]> wrote: > * Christian Babeux ([email protected]) wrote: >> Hi Zifei, >> >> Checking specific version numbers might be a bit counterproductive >> (e.g. what if some embedded platform as a GCC 4.7 with designated >> initializer explicitly patched out?). >> >> Going forward, I think checking for the designated initializer feature >> via a small C++ testfile is more in line with the Autoconf philosophy. >> Also, we should conditionally disable the compilation of the >> tracepoint probes requiring designated initializers if not supported. > > Moreover, the documentation and patches should take LLVM into account. > > Thanks, > > Mathieu > >> >> Thanks, >> >> Christian >> >> On Sat, Jun 15, 2013 at 2:08 PM, Zifei Tong <[email protected]> wrote: >> > Designated initializer support that is required to compile c++ >> > tracepoint probes is only available since g++ 4.7. >> > >> > Fixes #557 >> > >> > Signed-off-by: Zifei Tong <[email protected]> >> > --- >> > README | 3 ++- >> > configure.ac | 16 ++++++++++++++-- >> > 2 files changed, 16 insertions(+), 3 deletions(-) >> > >> > diff --git a/README b/README >> > index 1f6b9d2..1c7a2f8 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 with g++. To compile tracepoint >> > probes >> > + in g++, you need version 4.7 or above. >> > >> > >> > ENVIRONMENT VARIABLES: >> > diff --git a/configure.ac b/configure.ac >> > index 802ccaa..85a64a1 100644 >> > --- a/configure.ac >> > +++ b/configure.ac >> > @@ -83,9 +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_gcc_cxx_version=yes], >> > [rw_cv_prog_cxx_works=no]) >> > - AC_LANG_POP([C++])]) >> > + AC_LANG_POP([C++]) >> > + if test "$check_gcc_cxx_version" = "yes"; then >> > + gcc_cxx_version=`$CXX -dumpversion` >> > + gcc_cxx_major_version=$(echo $gcc_cxx_version | >> > sed >> > 's/^\([[0-9]]*\)\.[[0-9]]*.*$/\1/') >> > + gcc_cxx_minor_version=$(echo $gcc_cxx_version | >> > sed >> > 's/^[[0-9]]*\.\([[0-9]]*\).*$/\1/') >> > + if test "$gcc_cxx_major_version" -gt 4; then >> > + rw_cv_prog_cxx_works="yes" >> > + elif test "$gcc_cxx_major_version" -eq 4 -a >> > "$gcc_cxx_minor_version" -ge 7; then >> > + rw_cv_prog_cxx_works="yes" >> > + else >> > + rw_cv_prog_cxx_works="no" >> > + fi >> > + fi]) >> > >> > AM_CONDITIONAL([CXX_WORKS], [test "x$rw_cv_prog_cxx_works" = "xyes"]) >> > >> > -- >> > 1.8.3.1 >> > >> > -- >> > Best Regards, >> > 仝子飞 (Zifei Tong) >> > >> > _______________________________________________ >> > lttng-dev mailing list >> > [email protected] >> > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev >> >> _______________________________________________ >> lttng-dev mailing list >> [email protected] >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com > _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
