_Static_assert
From cppreference.com
_Static_assert evaluates a constant expression at compile time. If the expression is equal to 0, the compiler will produce an error message containing the string literal given as the second parameter.
This section is incomplete Reason: write a page on static_assert-declaration, move content from here |
[edit] Parameters
condition | - | constant expression |
str | - | string literal |
[edit] Return Value
(none)
[edit] Example
Run this code
#define BUFFER_SIZE 2048 int main (int argc, char **argv) { // Test if math works. _Static_assert(2 + 2 == 4, "Whoa dude!"); // This will produce an error at compile time. _Static_assert(BUFFER_SIZE <= 1024, "BUFFER_SIZE is too big"); return 0; }