Skip to content

Commit 32bbb4f

Browse files
edgar-bonetnoglitch
authored andcommitted
include/types.h: conditionally define bool, false and true
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]> Signed-off-by: Li Bin <[email protected]> Acked-by: Nicolas Ferre <[email protected]>
1 parent 1f5b2d6 commit 32bbb4f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ typedef signed long long s64;
2020
typedef unsigned long size_t;
2121
typedef signed long ssize_t;
2222

23+
/* bool, false and true are predefined since C23. */
24+
#if __STDC_VERSION__ < 202311L
2325
typedef unsigned char bool;
2426
#define false 0U
2527
#define true 1U
28+
#endif
2629

2730
#endif /* TYPES_H_ */

0 commit comments

Comments
 (0)