From 7d9430d8b1ccda56a0161b14b9e95b2dee0c3df4 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 6 Jul 2005 21:39:30 +0000 Subject: [PATCH] * NEWS: New macro AC_C_TYPEOF. * doc/autoconf.texi (C Compiler): Document AC_C_TYPEOF. * lib/autoconf/c.m4 (AC_C_TYPEOF): New macro. * tests/c.at (C keywords): Test AC_C_TYPEOF. --- ChangeLog | 5 +++++ NEWS | 3 +++ doc/autoconf.texi | 10 ++++++++++ lib/autoconf/c.m4 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/c.at | 7 ++++--- 5 files changed, 63 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16c574c5..3e5f3407 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-07-06 Paul Eggert + * NEWS: New macro AC_C_TYPEOF. + * doc/autoconf.texi (C Compiler): Document AC_C_TYPEOF. + * lib/autoconf/c.m4 (AC_C_TYPEOF): New macro. + * tests/c.at (C keywords): Test AC_C_TYPEOF. + Fix problems reported by Nicolas Joly. * tests/base.at (Input/Output): Ignore 'loading site script' chatter. * tests/local.at (AT_CONFIG_CMP): Ignore lines like "LIBS=''" too. diff --git a/NEWS b/NEWS index ee4b6ee4..95317115 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,9 @@ future release; the old style value, which matches (../)*, is (and will continue to be) available as ac_top_build_prefix. +** AC_C_TYPEOF + New macro to check for support of 'typeof' syntax a la GNU C. + ** AC_PROG_CC_C89, AC_PROG_CC_C99 New macros for ISO C99 support. AC_PROG_CC_C89 and AC_PROG_CC_C99 check for ANSI C89 and ISO C99 support respectively. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index f37cbb2b..1c06cfd6 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -5949,6 +5949,16 @@ found in macros such as this: @end example @end defmac +@defmac AC_C_TYPEOF +@acindex{C_TYPEOF} +@cvindex HAVE_TYPEOF +@cvindex typeof +If the C compiler supports GCC's @code{typeof} syntax, define +@code{HAVE_TYPEOF}. If the support is available only via a different +spelling of the keyword (e.g., @code{__typeof__}), define @code{typeof} +to that spelling. +@end defmac + @defmac AC_C_PROTOTYPES @acindex{C_PROTOTYPES} @cvindex PROTOTYPES diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index 4612019e..441f84a8 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -45,6 +45,7 @@ # to the GPL from your modified version. # # Written by David MacKenzie, with help from +# Akim Demaille, Paul Eggert, # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, # Roland McGrath, Noah Friedman, david d zuhn, and many others. @@ -1433,3 +1434,43 @@ else AC_MSG_RESULT([no]) fi ])# AC_C_PROTOTYPES + + +# AC_C_TYPEOF +# ----------- +# Check if the C compiler supports GCC's typeof syntax. +# The test case provokes incompatibilities in the Sun C compilers +# (both Solaris 8 and Solaris 10). +AC_DEFUN([AC_C_TYPEOF], +[ + AC_CACHE_CHECK([for typeof syntax and keyword spelling], ac_cv_c_typeof, + [ac_cv_c_typeof=no + for ac_kw in typeof __typeof__ no; do + test $ac_kw = no && break + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], + [[ + int value; + return + (! ((void) + ((struct { + char a [1 + + ! (($ac_kw (value)) + (($ac_kw (value)) 0 < ($ac_kw (value)) -1 + ? ($ac_kw (value)) - 1 + : ~ (~ ($ac_kw (value)) 0 + << sizeof ($ac_kw (value)))))]; } *) + 0), + 0)); + ]])], + [ac_cv_c_typeof=$ac_kw]) + test $ac_cv_c_typeof != no && break + done]) + if test $ac_cv_c_typeof != no; then + AC_DEFINE([HAVE_TYPEOF], 1, + [Define to 1 if typeof works with your compiler.]) + if test $ac_cv_c_typeof != typeof; then + AC_DEFINE_UNQUOTED([typeof], [$ac_cv_c_typeof], + [Define to __typeof__ if your compiler spells it that way.]) + fi + fi +]) diff --git a/tests/c.at b/tests/c.at index 3c640fe9..c963884c 100644 --- a/tests/c.at +++ b/tests/c.at @@ -74,14 +74,15 @@ AT_CLEANUP ## C keywords. ## ## ------------ ## -# GCC supports `const' and `volatile'. +# GCC supports `const', `typeof', and `volatile'. AT_CHECK_MACRO([C keywords], [[AC_PROG_CC AC_C_CONST +AC_C_TYPEOF AC_C_VOLATILE -case $GCC,$ac_cv_c_const,$ac_cv_c_volatile in +case $GCC,$ac_cv_c_const,$ac_cv_c_typeof,$ac_cv_c_volatile in yes,*no*) - AC_MSG_ERROR([failed to detect `const' or `volatile' support]);; + AC_MSG_ERROR([failed to detect `const', `typeof', or `volatile' support]);; esac ]])