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

Fix CPP compilation with IAR #1345

Merged
merged 1 commit into from
Feb 28, 2022

Conversation

alexandre-perrin
Copy link
Contributor

IAR defines STDC_VERSION in cpp as well.
Which causes TU_VERIFY_STATIC to be defined as _Static_assert
instead of cpp's static_assert.

This reorders cplusplus to be first, then to fallback to
STDC_VERSION if not CPP.

IAR defines __STDC_VERSION__ in cpp as well.
Which causes TU_VERIFY_STATIC to be defined as _Static_assert
instead of cpp's static_assert.

This reorders __cplusplus__ to be first, then to fallback to
__STDC_VERSION__ if not CPP.
@yoyopod
Copy link
Contributor

yoyopod commented Feb 23, 2022

I experienced this same problem with an IAR build, and fixed it in the exact manner proposed.

I have subsequently learned that C11 also defines a macro, 'static_assert', in assert.h, that maps to C11's '_Static_assert' keyword. Relying on the macro would allow the C and C++ cases both to use static_assert(), with no need to differentiate.

@HiFiPhile HiFiPhile self-requested a review February 23, 2022 21:56
@alexandre-perrin
Copy link
Contributor Author

Fixes #1344

@hathach hathach merged commit 8e84529 into hathach:master Feb 28, 2022
@alexandre-perrin alexandre-perrin deleted the iar-cpp-verify-static branch February 28, 2022 10:16
@alexandre-perrin alexandre-perrin restored the iar-cpp-verify-static branch March 4, 2022 17:59
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.

4 participants