Hello,

When building Bash on Ubuntu with GCC 15 using C23, the build fails because
bashansi.h attempts to typedef bool, which is a keyword in C23.

*Environment:*

gcc (Ubuntu 15.2.0-4ubuntu4) 15.2.0
Linux u25 6.17.0-6-generic x86_64 GNU/Linux

*Error log:*

../bashansi.h:44:23: error: ‘bool’ cannot be defined via ‘typedef’
note: ‘bool’ is a keyword with ‘-std=c23’ onwards
make[1]: *** [Makefile:231: mkbuiltins.o] Error 1

*Fix:*

Adding a check for C23 in bashansi.h allows Bash to compile successfully:

#if !defined (HAVE_C_BOOL)
-#  if defined (HAVE_STDBOOL_H)
+#  if __STDC_VERSION__ >= 202311L
+     /* C23: bool is a keyword */
+#    include <stdbool.h>
+#  elif defined (HAVE_STDBOOL_H)
#    include <stdbool.h>
#  else
#    undef bool
-typedef unsigned char bool;
+     typedef unsigned char bool;
#    define true 1
#    define false 0
#  endif
#endif

Please let me know if further information is needed.

Best regards,
Ahaoboy

Reply via email to