Skip to content

Comments

Fix compile error with GCC 15 (-std=c23)#12

Closed
ueno wants to merge 2 commits intosmuellerDD:masterfrom
ueno:wip/c23
Closed

Fix compile error with GCC 15 (-std=c23)#12
ueno wants to merge 2 commits intosmuellerDD:masterfrom
ueno:wip/c23

Conversation

@ueno
Copy link
Contributor

@ueno ueno commented Jan 22, 2025

When compiling on Fedora rawhide, it fails with:

In file included from ../internal/api/atomic_bool.h:23,
                 from ../internal/api/mutex_w.h:24,
                 from ../drng/src/seeded_rng.c:28:
../internal/api/bool.h:31:8: error: cannot use keyword ‘false’ as enumeration constant
   31 | enum { false, true };
      |        ^~~~~
../internal/api/bool.h:31:8: note: ‘false’ is a keyword with ‘-std=c23’ onwards
../internal/api/bool.h:32:15: error: ‘bool’ cannot be defined via ‘typedef’
   32 | typedef _Bool bool;
      |               ^~~~
../internal/api/bool.h:32:15: note: ‘bool’ is a keyword with ‘-std=c23’ onwards
../internal/api/bool.h:32:1: warning: useless type name in empty declaration
   32 | typedef _Bool bool;
      | ^~~~~~~

The first commit should fix it, though the second commit is just a cosmetics.

In C23, "true", "false", and "bool" are reserved keywords and cannot
be redefined:
https://en.wikipedia.org/wiki/C23_(C_standard_revision)#Keywords

Signed-off-by: Daiki Ueno <dueno@redhat.com>
Given <stdint.h> is already there, it wouldn't hurt to have
<stdbool.h> as well, as both headers are in the C99 standard.

Signed-off-by: Daiki Ueno <dueno@redhat.com>
@smuellerDD
Copy link
Owner

Applied, thanks

@smuellerDD smuellerDD closed this Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants