need to define _ISOC99_SOURCE
Akim Demaille
akim@epita.fr
Mon Jul 31 03:16:00 GMT 2000
Here is a proto patch. I send it mainly because I think we can
simplify the approach in Autoconf a lot: my proposal always defines
_GNU_SOURCE and _ALL_SOURCE, I don't think there is any advantage in
trying to check we run AIX before setting _ALL_SOURCE.
Also, I used a protected form for both (with ifndef guards). I don't
think it is useful as config.h is expected to be the first file
included. But some people seem to rely on it. In addition, there is
a comment:
/* Define if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
I still don't see how it could happen while being correct (config.h
must be first, mustn't it?).
Let's start with this, then we'll address the other symbols.
----------------------------------------------------------------------
Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.53
diff -u -r1.53 aclang.m4
--- aclang.m4 2000/07/31 09:22:47 1.53
+++ aclang.m4 2000/07/31 10:13:30
@@ -508,6 +508,30 @@
])# AC_LANG_COMPILER_WORKS
+# _AC_COMPILER_ENABLE_EXTENSIONS
+# ------------------------------
+# Define all the symbols that might give access to useful features.
+# AIX needs _ALL_SOURCE.
+# GNU needs _GNU_SOURCE.
+# We use AC_DEFINE to set these symbols in confdefs.h too.
+define([_AC_COMPILER_ENABLE_EXTENSIONS],
+[AH_VERBATIM([_ALL_SOURCE],
+[/* Define if on AIX 3.
+ System headers sometimes define this.
+ We just want to avoid a redefinition error message. */
+@%:@ifndef _ALL_SOURCE
+@%:@ define _ALL_SOURCE
+@%:@endif])dnl
+AC_DEFINE([_ALL_SOURCE])
+AH_VERBATIM([_GNU_SOURCE],
+[/* Define if using the GNU libc. */
+@%:@ifndef _GNU_SOURCE
+@%:@ undef _GNU_SOURCE
+@%:@endif])dnl
+AC_DEFINE([_GNU_SOURCE])
+])
+
+
# -------------------- #
# 3b. The C compiler. #
# -------------------- #
@@ -577,6 +601,7 @@
_AC_PROG_CC_G
AC_EXPAND_ONCE([_AC_EXEEXT])
AC_EXPAND_ONCE([_AC_OBJEXT])
+AC_EXPAND_ONCE([_AC_COMPILER_ENABLE_EXTENSIONS])
AC_LANG_POP
])# AC_PROG_CC
@@ -769,6 +794,7 @@
_AC_PROG_CXX_G
AC_EXPAND_ONCE([_AC_EXEEXT])
AC_EXPAND_ONCE([_AC_OBJEXT])
+AC_EXPAND_ONCE([_AC_COMPILER_ENABLE_EXTENSIONS])
AC_LANG_POP
])# AC_PROG_CXX
@@ -866,9 +892,9 @@
_AC_LANG_COMPILER_WORKS
_AC_PROG_F77_GNU
_AC_PROG_F77_G
-
AC_EXPAND_ONCE([_AC_EXEEXT])
AC_EXPAND_ONCE([_AC_OBJEXT])
+AC_EXPAND_ONCE([_AC_COMPILER_ENABLE_EXTENSIONS])
AC_LANG_POP
])# AC_PROG_F77
Index: acspecific.m4
===================================================================
RCS file: /cvs/autoconf/acspecific.m4,v
retrieving revision 1.289
diff -u -r1.289 acspecific.m4
--- acspecific.m4 2000/07/19 09:20:58 1.289
+++ acspecific.m4 2000/07/31 10:13:39
@@ -2842,26 +2842,7 @@
# AC_AIX
# ------
-AC_DEFUN([AC_AIX],
-[AH_VERBATIM([_ALL_SOURCE],
-[/* Define if on AIX 3.
- System headers sometimes define this.
- We just want to avoid a redefinition error message. */
-#ifndef _ALL_SOURCE
-# undef _ALL_SOURCE
-#endif])dnl
-AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
-AC_BEFORE([$0], [AC_TRY_RUN])dnl
-AC_MSG_CHECKING(for AIX)
-AC_EGREP_CPP(yes,
-[#ifdef _AIX
- yes
-#endif
-],
-[AC_MSG_RESULT(yes)
-AC_DEFINE(_ALL_SOURCE)],
-AC_MSG_RESULT(no))
-])# AC_AIX
+AU_DEFUN([AC_AIX], [])
# AC_MINIX
----------------------------------------------------------------------
I am also tempted to define unconditionally these symbols:
#define _POSIX_SOURCE 1
#define _POSIX_1_SOURCE 2
since they cover those two macros:
| # AC_MINIX
| # --------
| AC_DEFUN([AC_MINIX],
| [AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
| AC_BEFORE([$0], [AC_TRY_RUN])dnl
| AC_CHECK_HEADER(minix/config.h, MINIX=yes, MINIX=)
| if test "$MINIX" = yes; then
| AC_DEFINE(_POSIX_SOURCE, 1,
| [Define if you need to in order for `stat' and other things to
| work.])
| AC_DEFINE(_POSIX_1_SOURCE, 2,
| [Define if the system does not provide POSIX.1 features except
| with this defined.])
| AC_DEFINE(_MINIX, 1,
| [Define if on MINIX.])
| fi
| ])# AC_MINIX
| # AC_ISC_POSIX
| # ------------
| AC_DEFUN([AC_ISC_POSIX],
| [AC_REQUIRE([AC_PROG_CC])dnl
| AC_BEFORE([$0], [AC_TRY_COMPILE])dnl
| AC_BEFORE([$0], [AC_TRY_RUN])dnl
| AC_MSG_CHECKING(for POSIXized ISC)
| if test -d /etc/conf/kconfig.d &&
| grep _POSIX_VERSION [/usr/include/sys/unistd.h] >/dev/null 2>&1
| then
| AC_MSG_RESULT(yes)
| ISC=yes # If later tests want to check for ISC.
| AC_DEFINE(_POSIX_SOURCE, 1,
| [Define if you need to in order for stat and other things to
| work.])
| if test "$GCC" = yes; then
| CC="$CC -posix"
| else
| CC="$CC -Xp"
| fi
| else
| AC_MSG_RESULT(no)
| ISC=
| fi
| ])# AC_ISC_POSIX
More information about the Libc-alpha
mailing list