]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* tests/semantics.at (AC_CHECK_SIZEOF): Split into two tests: one
authorAkim Demaille <akim@epita.fr>
Wed, 30 Jan 2002 15:11:49 +0000 (15:11 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 30 Jan 2002 15:11:49 +0000 (15:11 +0000)
for plain code, the other for cross-compilation code.  The latter
is now run with GCC only.
* doc/autoconf.texi (Compilers and Preprocessors): New.

ChangeLog
doc/autoconf.texi
tests/semantics.at

index dac98f497a120ab569b1f80f74855072b4635f14..57472ff134ba74c52fef78433e7e26040f4f8eef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-01-30  Akim Demaille  <akim@epita.fr>
+
+       * tests/semantics.at (AC_CHECK_SIZEOF): Split into two tests: one
+       for plain code, the other for cross-compilation code.  The latter
+       is now run with GCC only.
+       * doc/autoconf.texi (Compilers and Preprocessors): New.
+
 2002-01-30  Akim Demaille  <akim@epita.fr>
 
        * lib/autoconf/general.m4 (_AC_INIT_PACKAGE): Support pre-defined
index a27bd9320b45cb8650bfd218b5fec8cf1c38b1e6..ec25afcaf9b2ee8fb8f613445b6103a8b022f4bb 100644 (file)
@@ -274,6 +274,7 @@ Types
 
 Compilers and Preprocessors
 
+* Specific Compiler Characteristics::  Some portability issues
 * Generic Compiler Characteristics::  Language independent tests
 * C Compiler::                  Checking its characteristics
 * C++ Compiler::                Likewise
@@ -4633,12 +4634,47 @@ fail too.  @xref{Manual Configuration}, for more on support for cross
 compiling.
 
 @menu
+* Specific Compiler Characteristics::  Some portability issues
 * Generic Compiler Characteristics::  Language independent tests
 * C Compiler::                  Checking its characteristics
 * C++ Compiler::                Likewise
 * Fortran 77 Compiler::         Likewise
 @end menu
 
+@node Specific Compiler Characteristics
+@subsection Specific Compiler Characteristics
+
+Some compilers exhibit different behaviors.
+
+@table @asis
+@item Static/Dynamic Expressions
+Autoconf relies on a trick to extract one bit of information from the C
+compiler: using negative array sizes.  For instance the following
+excerpt of a C source demonstrates how to test whether @samp{int}s are 4
+bytes long:
+
+@example
+int
+main (void)
+@{
+  static int test_array [(unsigned long) (sizeof (int)) == 4 ? 1 : -1];
+  test_array [0] = 0
+  return 0;
+@}
+@end example
+
+@noindent
+To our knowledge, there is a single compiler that does not support this
+trick: the HP C compilers (the real one, not only the ``bundled'') on
+HP-UX 11.00:
+
+@example
+$ @kbd{cc -c -Ae +O2 +Onolimit conftest.c}
+cc: "conftest.c": error 1879: Variable-length arrays cannot \
+    have static storage.
+@end example
+@end table
+
 @node Generic Compiler Characteristics
 @subsection Generic Compiler Characteristics
 
index 4fff3f67885c52a0b7aad02d7b3cdbb7f9d03557..51a0f5834123a30acb093bbb57fc899493be708a 100644 (file)
@@ -156,27 +156,48 @@ AT_CHECK_MACRO([AC_CHECK_MEMBERS],
 
 # AC_CHECK_SIZEOF
 # ---------------
+# Not cross-compiling.
 AT_CHECK_MACRO([AC_CHECK_SIZEOF],
 [[AC_CHECK_SIZEOF(char)
 AC_CHECK_SIZEOF(charchar,,
 [[#include <stdio.h>
 typedef char charchar[2];]])
 AC_CHECK_SIZEOF(charcharchar)
+]],
+[AT_CHECK_DEFINES(
+[#define SIZEOF_CHAR 1
+#define SIZEOF_CHARCHAR 2
+#define SIZEOF_CHARCHARCHAR 0
+])])
+
 
-# Exercize the code used when cross-compiling
+# AC_CHECK_SIZEOF
+# ---------------
+# Cross-compiling: only with GCC, as some compilers, such as HP's
+# cannot grok our trick:
+#
+# static int test_array [1 - 2 * !(((unsigned long) (sizeof (unsigned char))) >= 0)];
+#
+# configure:3637: cc -c -Ae +O2 +Onolimit  conftest.c >&5
+# cc: "configure", line 3660: error 1879: Variable-length arrays cannot have static storage.
+#
+AT_CHECK_MACRO([AC_CHECK_SIZEOF],
+[[# Exercize the code used when cross-compiling
+AC_PROG_CC
+if test "$GCC" != yes; then
+  exit 77
+fi
 cross_compiling=yes
-AC_CHECK_SIZEOF(unsigned char)
-AC_CHECK_SIZEOF(ucharchar,,
+AC_CHECK_SIZEOF(char)
+AC_CHECK_SIZEOF(charchar,,
 [[#include <stdio.h>
-typedef unsigned char ucharchar[2];]])
-AC_CHECK_SIZEOF(ucharcharchar)]],
+typedef char charchar[2];]])
+AC_CHECK_SIZEOF(charcharchar)
+]],
 [AT_CHECK_DEFINES(
 [#define SIZEOF_CHAR 1
 #define SIZEOF_CHARCHAR 2
 #define SIZEOF_CHARCHARCHAR 0
-#define SIZEOF_UCHARCHAR 2
-#define SIZEOF_UCHARCHARCHAR 0
-#define SIZEOF_UNSIGNED_CHAR 1
 ])])