Bruno Haible <[email protected]> writes:

> Simon Josefsson wrote:
>> rlogind.c: In function 'rlogind_mainloop':
>> rlogind.c:1112:7: error: expected identifier or '(' before numeric constant
>>  1112 |   int true;
>>       |       ^~~~
>> 
>> The file does not include stdbool.h.  ...
>> 
>> Does C23 disallow this?
>
> Yes. C23 ยง 6.4.1 states that true and false are now keywords. This precludes
> the use as variable names.

Thanks for analysis and the pointer!  How can I trigger that without
gnulib's config.h?  Shouldn't the following cause a compilation error?

$ podman run -it gcc:latest
root@18544d251872:/# cat>foo.c
int main (void) {
int true = 42;
return true;
}
^D
root@18544d251872:/# gcc --version
gcc (GCC) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@18544d251872:/# gcc -std=gnu2x -o foo foo.c -Wall -Wpedantic -Wextra
root@18544d251872:/# 

> So, that source code will need to change to conform to C23.
>
> With Gnulib, you can opt to avoid the 'stdbool' module and use 'stdbool-c99'.
> This will avoid this compilation error in rlogind.c, but many Gnulib modules
> will not compile in this setting.

I changed the variable names here instead.

/Simon

Attachment: signature.asc
Description: PGP signature

Reply via email to