Skip to content

Make code C23 compliant#22

Open
dagargo wants to merge 1 commit intokorginc:masterfrom
dagargo:feature/make-code-c23-compliant
Open

Make code C23 compliant#22
dagargo wants to merge 1 commit intokorginc:masterfrom
dagargo:feature/make-code-c23-compliant

Conversation

@dagargo
Copy link

@dagargo dagargo commented Sep 10, 2025

This commit fixes a compilation error that appears when gcc is set to use the C23 standard.

volcasample/project$ git diff -U0 
diff --git a/project/Makefile b/project/Makefile
index cd235f3..cb5df73 100644
--- a/project/Makefile
+++ b/project/Makefile
@@ -12 +12 @@ RM = rm -f
-CFLAGS = -O3 -Wall -W -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings \
+CFLAGS = --std=c23 -O3 -Wall -W -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings \

volcasample/project$ make
gcc --std=c23 -O3 -Wall -W -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wfloat-equal -Wpointer-arith -fPIC   -c -o ../syro/korg_syro_comp.o ../syro/korg_syro_comp.c
In file included from ../syro/korg_syro_comp.c:7:
../syro/korg_syro_type.h:35:13: error: two or more data types in declaration specifiers
   35 | typedef int bool;
      |             ^~~~
../syro/korg_syro_type.h:35:1: warning: useless type name in empty declaration
   35 | typedef int bool;
      | ^~~~~~~
make: *** [<builtin>: ../syro/korg_syro_comp.o] Error 1

More precisely, the failure happens because C23 introduces a bool keyword. See https://gcc.gnu.org/projects/c-status.html#c23.

The reason for this PR is that C23 is used as the default language version in gcc version 15. See https://gcc.gnu.org/gcc-15/changes.html#c. Albeit it's quite a new version, it's already used by some.

The explanation for the strange value 202000 of the __STDC_VERSION__ macro comes from the fact that this internal version was the first one in gcc including this bool feature before the official value 202311 was out. In fact, this is the value gcc 14 returns for c23 but, since the version are monotonic numbers, this shouldn't be an issue. There is a more thorough explanation in https://stackoverflow.com/questions/78581920/what-is-the-stdc-version-value-for-c23.

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.

1 participant