How can compile-time static asserts be implemented in C (not C++), with particular emphasis on GCC?
How can compile-time static asserts be implemented in C (not C++), with particular emphasis
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
C11 standard adds the
_Static_assertkeyword.This is implemented since gcc-4.6:
The first slot needs to be an integral constant expression. The second slot is a constant string literal which can be long (
_Static_assert(0, L"assertion of doom!")).I should note that this is also implemented in recent versions of clang.