Re: bool and C23

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

 



On 8/22/22 15:58, Zack Weinberg wrote:
There isn’t a bool module right now, are you proposing to add one?

Yes.


I want to get to where _no_ Gnulib module is required for
bool; AC_C_BOOL by itself should be enough.

Yes, that's the long term goal. But in the shorter term Gnulib-using code can't yet require Autoconf 2.72+ so it will need to use a new module in Gnulib (maybe it should be called c-bool instead of bool). This module will merely say "You should use AC_C_BOOL" and will contain an implementation of AC_C_BOOL for use in Autoconf 2.71-. The substitute implementation should be a copy of what's in Autoconf 2.72.


Sure, but why can't the non-autoheader case define bool, false, and true
instead of defining C_BOOL_DEFINITION? That will keep the code simpler
for these people.
I don’t understand what you are suggesting here.

My idea is that for the non-autoheader case, where #defines are implemented via -D options given to the compiler, Autoconf arranges to pass '-D bool=_Bool -D true=1 -D false=0' to compilers that don't have either bool  or stdbool.h. That way, user code need not ever #define bool or true or false; non-autoheader user code can say just this:

  #if defined C_NEED_STDBOOL_H && !defined __cpluplus
  # include <stdbool.h>
  #endif

and autoheader user code (the typical case) need not say anything other than the usual "#include <config.h>".

Admittedly this is only a minor improvement, as I think pretty much everybody who uses Autoconf and C also uses Autoheader and config.h.


Looking at the existing Gnulib code, though, suggests another possible
reason why we might need the fallback code to `signed char` (or
Gnulib’s enumeration): allegedly C99-compliant compilers whose Boolean
implementation is buggy.  My AC_C_BOOL preserves the existing test for
a buggy Boolean type, from AC_CHECK_HEADER_STDBOOL, so, if we do as
Paul suggests and make configure error out when there’s no usable
Boolean, that will hard reject those compilers as well.  I’m fine with
that.  Are you fine with that?

That should be OK as far as I know; Bruno may have further thoughts.

One other issue comes to mind: bool bitfield in structs. Although Autoconf currently tests that these compile, it doesn't test that bool bitfields of width 1 have the same memory layout as unsigned int bitfields of width 1. Emacs has this issue and already addresses it (look for "bool_bf" in the Emacs source). I don't think Autoconf needs to worry about bool bitfield implementation, as (a) the issue comes up pretty rarely and (b) neither current Autoconf nor current Gnulib addresses or solves the issue. However, the issue might be worth documenting in Autoconf.






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

  Powered by Linux