+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
Compilers and Preprocessors
+* Specific Compiler Characteristics:: Some portability issues
* Generic Compiler Characteristics:: Language independent tests
* C Compiler:: Checking its characteristics
* C++ Compiler:: Likewise
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
# 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
])])