From 9a358e5cc3977fd6121f12dd25a358081fd77041 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 21 Mar 2008 12:38:02 +0000 Subject: [PATCH] m4/gst-dowhile.m4: Add macro that checks if the compiler supports do {} while (0) macros and define HAVE_DOWHILE_MACR... Original commit message from CVS: * m4/gst-dowhile.m4: Add macro that checks if the compiler supports do {} while (0) macros and define HAVE_DOWHILE_MACROS if it does. This is needed by glib/gmacros.h to use something else than if (1) else for G_STMT_START/END when compling C++, which causes compiler warnings because of ambigious else with g++ 4.3. --- ChangeLog | 9 +++++++++ m4/gst-dowhile.m4 | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 m4/gst-dowhile.m4 diff --git a/ChangeLog b/ChangeLog index f22c4cf..5a87e22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-03-21 Sebastian Dröge + + * m4/gst-dowhile.m4: + Add macro that checks if the compiler supports do {} while (0) + macros and define HAVE_DOWHILE_MACROS if it does. This is + needed by glib/gmacros.h to use something else than + if (1) else for G_STMT_START/END when compling C++, which + causes compiler warnings because of ambigious else with g++ 4.3. + 2008-03-21 Sebastian Dröge * m4/gst-plugin-docs.m4: diff --git a/m4/gst-dowhile.m4 b/m4/gst-dowhile.m4 new file mode 100644 index 0000000..a5605d7 --- /dev/null +++ b/m4/gst-dowhile.m4 @@ -0,0 +1,24 @@ +dnl +dnl Check for working do while(0) macros. This is used by G_STMT_START +dnl and G_STMT_END in glib/gmacros.h. Without having this defined we +dnl get "ambigious if-else" compiler warnings when compling C++ code. +dnl +dnl Copied from GLib's configure.in +dnl +AC_DEFUN([AG_GST_CHECK_DOWHILE_MACROS],[ + +dnl *** check for working do while(0) macros *** +AC_CACHE_CHECK([for working do while(0) macros], g_support_dowhile_macros, [ + AC_TRY_COMPILE([],[ + #define STMT_START do + #define STMT_END while(0) + #define STMT_TEST STMT_START { i = 0; } STMT_END + int main(void) { int i = 1; STMT_TEST; return i; }], + [g_support_dowhile_macros=yes], + [g_support_dowhile_macros=no], + [g_support_dowhile_macros=yes]) +]) +if test x$g_support_dowhile_macros = xyes; then + AC_DEFINE(HAVE_DOWHILE_MACROS, 1, [define for working do while(0) macros]) +fi +]) -- 2.34.1