diff options
author | Zack Weinberg <zackw@panix.com> | 2020-12-06 11:40:39 -0500 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2020-12-06 11:40:39 -0500 |
commit | b045574cb2ea1c8441be7a7b56fd471d704ebf3a (patch) | |
tree | 4e93553716d40939551f142b3b2121f5cbe59a42 /NEWS | |
parent | c467efab94cd2d0331655d68d067fa0719fc8762 (diff) | |
download | autoconf-b045574cb2ea1c8441be7a7b56fd471d704ebf3a.tar.gz |
AC_INCLUDES_DEFAULT: Check for presence of C90 hosted headers (#110393)
Since 1993, Autoconf has been assuming that it is safe to include any
of the headers defined by ISO C90 without checking for them; this is
inaccurate, since only a subset are necessarily available in a
C90 *freestanding* environment.
It is OK to assume the presence of a header in a macro that checks
specifically for something declared by that header (if the header is
not present, we will think the specific declaration is unavailable,
which is probably accurate for modern embedded environments). It is
also OK to continue recommending that user code use these headers
unconditionally—anyone working with a freestanding environment knows
it. But it is not OK for very generic code within Autoconf itself,
such as AC_INCLUDES_DEFAULT, to make this assumption.
Note that the set of headers that are not always available includes
stdio.h, which we have been assuming can be included unconditionally
for even longer.
In AC_INCLUDES_DEFAULT, revert to checking for string.h and stdlib.h
before including them. Also revert to defining STDC_HEADERS only when
string.h and stdlib.h are available (but do not check for float.h and
stdarg.h, as these are part of the freestanding set). Add a new check
for stdio.h. Sort the inclusion list by standard (C90 freestanding;
C90 hosted; C99; POSIX) and alphabetically within each group. Revise
all the documentation and update the testsuite.
This partially reverts commit 86c213d0e355296f026a36e3203c0813041aae89
and is a partial fix for bug #110393.
* lib/autoconf/headers.m4 (AC_CHECK_INCLUDES_DEFAULT): Check for
stdio.h, stdlib.h, and string.h before including them. Define
STDC_HEADERS only when string.h and stdlib.h are both available.
Organize includes list by standard, then alphabetically.
* doc/autoconf.texi, NEWS: Update to match.
* tests/local.at (AT_CHECK_DEFINES): Make regexes more specific.
Also expect a definition of HAVE_STDIO_H.
* tests/c.at, tests/semantics.at, tests/tools.at: Use <float.h>,
not <stdio.h>, as a header that we expect always to exist.
Add HAVE_STDIO_H to various lists of macros that are expected to
appear in config.h.
Diffstat (limited to 'NEWS')
-rw-r--r-- | NEWS | 28 |
1 files changed, 17 insertions, 11 deletions
@@ -136,19 +136,25 @@ GNU Autoconf NEWS - User visible changes. *** AC_INCLUDES_DEFAULT assumes an ISO C90 compliant C implementation. - Specifically, it assumes that the ISO C90 headers <stdlib.h> and - <string.h> are available, without checking for them, and does not - include the pre-standard header <memory.h> at all. If the POSIX - header <strings.h> exists, it will be included, without testing - whether it is safe to include both <string.h> and <strings.h> in the + Specifically, it assumes that the ISO C90 header <stddef.h> + is available, without checking for it, and it does not include + the pre-standard header <memory.h> at all. If the POSIX header + <strings.h> exists, it will be included, without first testing + whether both <string.h> and <strings.h> can be included in the same source file. - For compatibility’s sake, the C preprocessor macros STDC_HEADERS, - HAVE_STDLIB_H, and HAVE_STRING_H are defined unconditionally. - These preprocessor macros should be considered obsolescent. - However, cache variables like ac_cv_header_stdlib_h are not set; - this is intentional, so that AC_CHECK_HEADER([stdlib.h]) will still - do a test for the presence of stdlib.h, in case you genuinely need that. + AC_INCLUDES_DEFAULT still checks for the existence of <stdlib.h>, + <string.h>, and <stdio.h>, because these headers may not exist + in a “freestanding environment” (a compilation mode intended for OS + kernels and similar, where most of the features of the C library are + optional). Most programs need not use ‘#ifdef HAVE_STDLIB_H’ etc in + their own code. + + For compatibility’s sake, the C preprocessor macro STDC_HEADERS + will be defined when both <stdlib.h> and <string.h> are available; + however, <stdarg.h> and <float.h> are no longer checked for + (these, like <stddef.h>, are required to exist in a freestanding + environment). New code should not refer to this macro. Future releases of Autoconf may reduce the set of headers checked for by AC_INCLUDES_DEFAULT. |