Re: C23 support in Autoconf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.





[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux