X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=m4%2Frw_prog_cxx_works.m4;fp=m4%2Frw_prog_cxx_works.m4;h=1950d94d08692ac607e4284eb513b687f73da245;hp=0000000000000000000000000000000000000000;hb=a9c2df2bfce7a27b53ee5d5101f259f3e1f506b1;hpb=5a1c0a75771c4b95f9518be0e1960a25bb691caf;ds=sidebyside diff --git a/m4/rw_prog_cxx_works.m4 b/m4/rw_prog_cxx_works.m4 new file mode 100644 index 000000000..1950d94d0 --- /dev/null +++ b/m4/rw_prog_cxx_works.m4 @@ -0,0 +1,37 @@ +# rw_PROG_CXX_WORKS +# +# Check whether the C++ compiler works. There's a bit of oversight in +# autoconf that will set the C++ compiler to g++ if no compiler is found, +# even if g++ is not present! So we need an extra test to make sure that +# the compiler works. +# Script copied from the lttng-ust project. +# +AC_DEFUN([rw_PROG_CXX_WORKS], [ +AC_REQUIRE([AC_PROG_CXX]) +AC_CACHE_CHECK([whether the C++ compiler works], + [rw_cv_prog_cxx_works], + [AC_LANG_PUSH([C++]) + + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [ + check_cxx_designated_initializers=yes + ], [ + rw_cv_prog_cxx_works=no + ]) + + AS_IF([test "x$check_cxx_designated_initializers" = "xyes"], [ + 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 + ]) + ]) + + AC_LANG_POP([C++]) +]) +])