Skip to content

Fix build failure with GCC 15 #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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 <bonet@grenoble.cnrs.fr>
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