autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_CHECK_SIZEOF


From: Paul Eggert
Subject: Re: AC_CHECK_SIZEOF
Date: Fri, 13 Apr 2007 00:56:28 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

> Would you prefer the testsuite to be adjusted (skip the `AC_CHECK_SIZEOF
> struct' tests if CC is a C++ compiler) and thus match your doc change,
> or rather have AC_CHECK_SIZEOF be specifically different for C++ like
> AC_CHECK_TYPE is now?  At least in the former case I think NEWS should
> mention this functionality regression.

On further thought, let's just remove the special case for C++
entirely.  I don't think anybody's relying on it.  It seems a very
strange thing to rely on.  I think it's a relic of the old way that
AC_CHECK_SIZEOF used to work.

> Also, allowing objects for AC_CHECK_TYPE* should have a test, no?

I suppose so; feel free to contribute it.  Right now there are too
many tests for my machine ("make maintainer-check" takes _forever_) so
I admit to having some motivation problems in adding more.

I installed this:

2007-04-12  Paul Eggert  <address@hidden>

        * NEWS: Document recent changes to AC_CHECK_ALIGNOF, AC_CHECK_SIZEOF,
        AC_CHECK_TYPE, AC_CHECK_TYPES.
        * doc/autoconf.texi (Generic types): C types must be type-names
        (the C terminology), not type-ids (the C++ term).  C++ types
        must not be anonymous.
        * lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW): Remove special case
        for C++; this drops support for anonymous struct and union types,
        which were problematic anyway.
        * tests/semantics.at (AC_CHECK_HEADERS_NEW): Adjust test to work even
        for C++.

Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.426
diff -u -p -r1.426 NEWS
--- NEWS        7 Apr 2007 05:54:25 -0000       1.426
+++ NEWS        13 Apr 2007 07:52:52 -0000
@@ -2,6 +2,20 @@

 ** AC_C_BIGENDIAN now supports universal binaries a la Mac OS X.

+** AC_CHECK_ALIGNOF's type argument T is now documented better: it must
+   be a string of tokens such that "T y;" is a valid member declaration
+   in a struct.
+
+** AC_CHECK_SIZEOF now accepts objects as well as types: the general rule
+   is that sizeof (X) works, then AC_CHECK_SIZEOF (X) should work.
+
+** AC_CHECK_TYPE and AC_CHECK_TYPES now work on any C type-name; formerly,
+   they did not work for function types.  In C++, they now work on any
+   type-id that can be the operand of sizeof; this is similar to C,
+   except it excludes anonymous struct and union types.  Formerly,
+   some (but not all) C++ types involving anonymous struct and union
+   were accepted, though this was not documented.
+
 ** Autoconf now requires GNU M4 1.4.5 or later.  Earlier versions of M4 have
    a bug in macro tracing that interferes with the interaction between
    Autoconf and Automake.  GNU M4 1.4.8 or later is recommended.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1146
diff -u -p -r1.1146 autoconf.texi
--- doc/autoconf.texi   12 Apr 2007 19:41:03 -0000      1.1146
+++ doc/autoconf.texi   13 Apr 2007 07:52:53 -0000
@@ -6120,13 +6120,11 @@ test macros.
 Check whether @var{type} is defined.  It may be a compiler builtin type
 or defined by the @var{includes} (@pxref{Default Includes}).

-In C, @var{type} must be a type-id, so that the expression @samp{sizeof
+In C, @var{type} must be a type-name, so that the expression @samp{sizeof
 (@var{type})} is valid (but @samp{sizeof ((@var{type}))} is not).  The
-rules in C++ are currently more complicated and restrictive: @var{type}
-must be a string of tokens such that @samp{typedef @var{type} foo;} is a
-valid type definition.  However, the C++ approach has problems (for
-example, it mishandles function types) and may change in future versions
-of Autoconf.
+same test is applied when compiling for C++, which means that in C++
address@hidden should be a type-id and should not be an anonymous
address@hidden or @samp{union}.
 @end defmac


@@ -6242,7 +6240,7 @@ defines @code{SIZEOF_INT_P} to be 8 on D
 @defmac AC_CHECK_ALIGNOF (@var{type}, @dvar{includes, default-includes})
 @acindex{CHECK_ALIGNOF}
 Define @address@hidden (@pxref{Standard Symbols}) to be the
-alignment in bytes of @var{type}.  @address@hidden x;} must be valid as
+alignment in bytes of @var{type}.  @address@hidden y;} must be valid as
 a structure member declaration.  If @samp{type} is unknown, the result
 is 0.  If no @var{includes} are specified, the default includes are used
 (@pxref{Default Includes}).
Index: lib/autoconf/types.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/types.m4,v
retrieving revision 1.51
diff -u -p -r1.51 types.m4
--- lib/autoconf/types.m4       12 Apr 2007 00:12:06 -0000      1.51
+++ lib/autoconf/types.m4       13 Apr 2007 07:52:53 -0000
@@ -141,33 +141,19 @@
 #        if (sizeof (TYPE))
 #
 # to `read' sizeof (to avoid warnings), while not depending on its type
-# (not necessarily size_t etc.).  Equally, instead of defining an unused
-# variable, we just use a cast to avoid warnings from the compiler.
+# (not necessarily size_t etc.).
 #
-# Now, the next issue is that C++ disallows defining types inside casts
-# and inside `sizeof()', but we would like to allow unnamed structs, for
-# use inside AC_CHECK_SIZEOF, for example.  So for C++ we create a typedef
-# of the new type.  Note that this breaks for some types, e.g., function
-# types, but we don't know C++ well enough to fix this.
+# C++ disallows defining types inside `sizeof ()', but that's OK,
+# since we don't want to consider unnamed structs to be types for C++,
+# precisely because they don't work in cases like that.
 m4_define([_AC_CHECK_TYPE_NEW],
 [AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
 AC_CACHE_CHECK([for $1], [ac_Type],
 [AS_VAR_SET([ac_Type], [no])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])
-#ifdef __cplusplus
-typedef $1 ac__type_new_;
-#endif
-],
-[#ifdef __cplusplus
-if ((ac__type_new_ *) 0)
-  return 0;
-if (sizeof (ac__type_new_))
-  return 0;
-#else
-if (sizeof ($1))
-  return 0;
-#endif
-])],
+AC_COMPILE_IFELSE(
+  [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
+     [if (sizeof ($1))
+       return 0;])],
   [AC_COMPILE_IFELSE(
      [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
        [if (sizeof (($1)))
Index: tests/semantics.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/semantics.at,v
retrieving revision 1.60
diff -u -p -r1.60 semantics.at
--- tests/semantics.at  1 Mar 2007 00:18:28 -0000       1.60
+++ tests/semantics.at  13 Apr 2007 07:52:53 -0000
@@ -302,13 +302,13 @@ AC_CHECK_SIZEOF(charcharchar)
 # ----------------------
 AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF struct],
 [[AC_C_CONST
-AC_CHECK_SIZEOF([struct { char c; int x; }])
-AC_CHECK_SIZEOF([const struct { const char *p; int x; }])
+AC_CHECK_SIZEOF([struct x], [], [struct x { char c; int x; };])
+AC_CHECK_SIZEOF([const struct x], [], [struct x { const char *p; int x; };])
 AC_CHECK_SIZEOF([struct nosuchstruct])
 ]],
-[AT_CHECK([[grep "#define SIZEOF_STRUCT___CHAR_C__INT_X___ [^0]" config.h]],
+[AT_CHECK([[grep "#define SIZEOF_STRUCT_X [^0]" config.h]],
         0, ignore)
-AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT___CONST_CHAR_PP__INT_X___ [^0]" 
config.h]],
+AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [^0]" config.h]],
         0, ignore)
 AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
         0, ignore)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]