summaryrefslogtreecommitdiff
path: root/acinclude.m4
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-06-25 16:50:38 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-06-25 16:50:38 +0000
commit35bde4fc99e73c78133e342257d07986d9d8d6b3 (patch)
treefd367896ecce2ead43dd001f3887caffd5ebba60 /acinclude.m4
parent8dc9716fc2e3f8d4d945fbf7ef02b59affd0c2c9 (diff)
downloadmpfr-35bde4fc99e73c78133e342257d07986d9d8d6b3.tar.gz
Added Static Assertion support (modified patch from Patrick).
* Added src/mpfr-sassert.h: implementation of static assertions. * src/mpfr-impl.h: include "mpfr-sassert.h". * acinclude.m4: test whether static assertions are supported. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8241 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m429
1 files changed, 29 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 6109d3750..e81a134a9 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -417,6 +417,35 @@ int main() {
])
CPPFLAGS="$saved_CPPFLAGS"
fi
+
+dnl Check if Static Assertions are supported.
+AC_MSG_CHECKING(for Static Assertion support)
+saved_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS -I$srcdir/src"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#define MPFR_USE_STATIC_ASSERT 1
+#include "mpfr-sassert.h"
+
+/* Test if Static Assertions work */
+MPFR_DECL_STATIC_ASSERT(sizeof(char) <= sizeof(int));
+
+int main() {
+ MPFR_DECL_STATIC_ASSERT(sizeof(int) <= sizeof(long));
+ int x;
+ x = 1;
+ MPFR_STAT_STATIC_ASSERT(sizeof(short) <= sizeof(int));
+ return 0;
+}
+ ]])],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE([MPFR_USE_STATIC_ASSERT],1,[Build MPFR with Static Assertions])
+ ],
+ [AC_MSG_RESULT(no)
+ ],
+ [AC_MSG_RESULT([cannot test, assume no])
+ ])
+CPPFLAGS="$saved_CPPFLAGS"
+
])
dnl end of MPFR_CONFIGS