Skip to content
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

options/internal: fix static asserts for pre-C++03 #1181

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

no92
Copy link
Member

@no92 no92 commented Oct 26, 2024

This commit correctly checks whether the C++ standard is new enough, and if so, uses the standard-defined static_assert. In the case of C, gcc and clang implement _Static_assert as an extension irrespective of the chosen C standard. Otherwise, we fall back to not checking the condition. We need to do the extern int hack in order to not produce errors in pedantic mode, as a single semicolon or (void)0 at file scope give warnings or errors then.

This was originally discovered when compiling libstdc++, which uses -std=gnu++98 and was throwing errors.

@no92 no92 requested a review from 64 October 26, 2024 13:50
This commit correctly checks whether the C++ standard is new enough, and
if so, uses the standard-defined `static_assert`. In the case of C, gcc
and clang implement `_Static_assert` as an extension irrespective of the
chosen C standard. Otherwise, we fall back to not checking the
condition. We need to do the `extern int` hack in order to not produce
errors in pedantic mode, as a single semicolon or `(void)0` at file
scope give warnings or errors then.
@no92 no92 changed the title options/internal: fix static asserts for pre-C++04 options/internal: fix static asserts for pre-C++03 Oct 26, 2024
@64
Copy link
Member

64 commented Oct 27, 2024

Can we try to enable C++ header checks in CI?

@avdgrinten avdgrinten added this pull request to the merge queue Oct 28, 2024
@avdgrinten
Copy link
Member

Merging this since it unbreaks the xbbs build.

Merged via the queue into managarm:master with commit ea90982 Oct 28, 2024
40 checks passed
@no92 no92 deleted the static-asserts branch October 29, 2024 11:31
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.

3 participants