From 35bde4fc99e73c78133e342257d07986d9d8d6b3 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Mon, 25 Jun 2012 16:50:38 +0000 Subject: 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 --- acinclude.m4 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'acinclude.m4') 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 -- cgit v1.2.1