Re: C23 support in Autoconf
Paul Eggert <[email protected]> Wed, 1 May 2024 11:59:39 -0700
| Newsgroups | gmane.comp.sysutils.autoconf.general |
|---|---|
| Organization | UCLA Computer Science Department |
| Message-ID | <[email protected]> |
On 2024-05-01 05:33, Nick Bowler wrote: > Just configure with CFLAGS=-std=c99 or whatever. I was thinking along the same line. We should keep things simple. Using CFLAGS is a documented way to specify the compiler flags, and ideally there would be no need for a new feature in this area. However, I have some qualms. './configure CFLAGS=-std=c99' works somewhat by accident, because it tries things in the following order: echo ' ... C23 test ... ' >conftest.c gcc -std=c99 conftest.c gcc -std=gnu23 -std=c99 conftest.c echo ' ... C11 test ... ' >conftest.c gcc -std=c99 conftest.c gcc -std=gnu11 -std=c99 conftest.c gcc -std:c11 -std=c99 conftest.c echo ' ... C99 test ... ' >conftest.c gcc -std=c99 conftest.c The last GCC invocation is the first one that works, so 'configure' announces that it has enabled C99 features. This approach works because GCC treats a later -std= option as overriding an earlier one. Does the same thing happen with other compilers? If not, there should be a way for the builder to say "Don't try to mess with the C standard version; just leave $CC alone". With current Autoconf on Savannah there's a hacky way to do that: ./configure CC='-std=c99' ac_cv_prog_cc_c23= but that sort of thing is not something we want to document, as it depends on the Autoconf version. So perhaps there should be a better way to disable the C standard version testing that AC_PROG_CC normally does.