]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* NEWS: New macro AC_C_TYPEOF.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 6 Jul 2005 21:39:30 +0000 (21:39 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 6 Jul 2005 21:39:30 +0000 (21:39 +0000)
* 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
NEWS
doc/autoconf.texi
lib/autoconf/c.m4
tests/c.at

index 16c574c59f9379525e809b79ee43e590fc694cf1..3e5f340707ef17ecd488486a190c78b3d55dc358 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-07-06  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * 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 ee4b6ee49f4053cb9e34bbb3789a3a91e5b169da..9531711541f7113d760dda2e21662ce70d582b62 100644 (file)
--- 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.
index f37cbb2b35b8ed54dd6e4b341f29ea7cc995a0e5..1c06cfd60a1cff58bdace2f114eb0d3761c6dfd9 100644 (file)
@@ -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
index 4612019e202b3faa003966d175d207fc91fc1966..441f84a80d2512ca9ee7795dbc75909d58000a3f 100644 (file)
@@ -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
+])
index 3c640fe903bd247c0a69378edce9c385c3da2580..c963884cf2c00212d429f1bb99ffcef10144bf85 100644 (file)
@@ -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
 ]])