Skip to content

Allowing -std=c2y flag, as an alias to c23#131

Open
aalmkainzi wants to merge 2 commits into
fuhsnn:mainfrom
aalmkainzi:allow-c2y-flag
Open

Allowing -std=c2y flag, as an alias to c23#131
aalmkainzi wants to merge 2 commits into
fuhsnn:mainfrom
aalmkainzi:allow-c2y-flag

Conversation

@aalmkainzi

Copy link
Copy Markdown
Contributor

Simple change. Ideally the -std=c2y flag should enable c2y extensions that slimcc implements, and -std=c23 should disable them. But this is fine.

@fuhsnn

fuhsnn commented Mar 7, 2026

Copy link
Copy Markdown
Owner

slimcc's target mode is roughly "what GCC/Clang allow under -std=cXX -Wno-pedantic", and all C2Y stuff currently implemented here are enabled by GCC under even -std=c89.
Yeah, doubled checked https://godbolt.org/z/To6fvf7bd.

The rule (which I believe GCC/Clang maintainers generally agree) is if the same syntax yield different result then it should be -std gated, but if something simply "won't appear" in older standard code, then it is enabled as extension unless -pedantic.

@aalmkainzi

Copy link
Copy Markdown
Contributor Author

I think the gcc example worked because of the countof header (probably expands to some __builtin if not C2y).

I tried using the _Countof keyword directly, and it didn't work in C89: https://godbolt.org/z/P7an9djao

@fuhsnn

fuhsnn commented Mar 7, 2026

Copy link
Copy Markdown
Owner

The error is for the // comment (C99) https://godbolt.org/z/9xa8jddhq

_Countof itself is the builtin: https://github.com/gcc-mirror/gcc/blob/9f99ee9d103dd70c18637271bb7f9b3efc926959/gcc/ginclude/stdcountof.h#L29
Underscore+uppercase is reserved like double underscore.

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.

2 participants