Re: How can Autoconf help with the transition to stricter compilation defaults?

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

 



On 11/10/22 15:19, Paul Eggert wrote:
> On 2022-11-10 09:16, Zack Weinberg wrote:
>> Changes to handle C23 built-in ‘bool’ better are under development but
>> the design has not yet been finalized.
> 
> [I'm cc'ing this to bug-gnulib too.]
> 
> To my mind this is the biggest outstanding issue in Autoconf as far as 
> C23 goes, as the upgrade path for Autoconf's existing bool support is 
> not entirely clear. As Florian mentioned, distros can't assume Autoconf 
> upgrades when building other packages; that being said, we should get 
> Autoconf's bool support fixed sooner rather than later as bool hassles 
> will remain until Autoconf is fixed and these fixes are propagated to 
> Autoconf's users.
> 
> Here's the main Autoconf issue issue with bool. Traditionally, Autoconf 
> supported K&R C, C89, C99, etc. At some point (I'm not sure when), 
> Autoconf started requiring C89 or later. Is it now OK for Autoconf to 
> require C99 or later, as far as bool is concerned? If so, that'll 
> considerably simplify the ongoing maintenance hassle for bool.
> 
> Requiring C99-or-later bool is the option that Gnulib has taken. Its 
> 'stdbool' module and its gl_C_BOOL macro assumes C99 or later, and as 
> far as I know no Gnulib-using package is using Gnulib's 'stdbool-c99' 
> module which we kept around in case somebody still needed bool to work 
> atop a C89 system. (We considered supporting C23 bool atop C89 but it 
> was too painful.)

I am fine with this option.

> If we follow Gnulib's lead, Autoconf will generate a config.h that does 
> "#include <stdbool.h>" on pre-C23 systems

At least in the case of config.h files that could be included in external
programs, I recommend unconditionally generating “#include <stdbool.h>”.
That will ensure pre-C23 code that includes these headers builds okay.
I believe that in C23 and above this is a harmless no-op, as it is in C++.

> and this config.h will not 
> not work on pre-C99 systems. This of course could in theory break some 
> programs, just as compiling them with C23 can break them. But I don't 
> see any better option at this point. And besides, what package outside 
> of a museum still requires C89 and don't work with C99?

I just checked and both GCC 12.2 and clang 14 support <stdbool.h> in C89
mode.  I do get a -Wc99-extensions warning from clang but that can easily
be suppressed with -Wno-c99-extensions.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)

Attachment: OpenPGP_0xB288B55FFF9C22C1.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


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

  Powered by Linux