Skip to content

Conversation

edgar-bonet
Copy link
Contributor

Building with GCC 15 fails with:

include/types.h:23:23: error: ‘bool’ cannot be defined via ‘typedef’
   23 | typedef unsigned char bool;
      |                       ^~~~
include/types.h:23:23: note: ‘bool’ is a keyword with ‘-std=c23’ onwards

This is because GCC 15 default to the C23 dialect of C, which predefines bool (and false and true) as keywords.

This pull request fixes the build failure by conditioning the definitions of bool, false and true on the C dialect in use. Alternative approaches could be:

  • include <stdbool.h>, which should work on all C versions since C99 (but is deprecated in C23)
  • request a specific C dialect with the appropriate -std=… compiler flag in the Makefile

include/types.h typedefs ‘bool’ and macro-defines ‘false’ and ‘true’.
However, since C23, these are predefine keywords. As C23 is the default
C dialect for GCC 15, building with this compiler fails with:

    include/types.h:23:23: error: ‘bool’ cannot be defined via ‘typedef’
       23 | typedef unsigned char bool;
          |                       ^~~~
    include/types.h:23:23: note: ‘bool’ is a keyword with ‘-std=c23’ onwards

Fix this build failure by only defining ‘bool’, ‘false’ and ‘true’ on C
dialects older than C23.

Signed-off-by: Edgar Bonet <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant