static_assert

Full prototype:

_Static_assert(constant-expression, string-literal);  

Purpose and Notes:

A function-like macro that evaluates at compile-time the expression passed in as the first argument that should never be true. If the expression does evaluate to a C-style true (non zero), than abort compilation and print the error message passed in as the second argument. Otherwise continue compilation.

Essentially this function can be used for creating tests, sanity checks, and for aborting compilation on exceptions and logical flaws that the program doesn't want to recover from or handle in another way.

Not included in the final binary so speed and memory consumption is not a problem. The biggest complaint about this macro is a lot of programmers do not like the idea of flooding their codebase with them making the code longer and harder to read.

Returns:

void- Compilation macro, nothing returned as it is not included in the final binary of the code.

Argument 1:

Constant-expression- an expression that compares equal to an integer value and can be known during compilation, and thus is not an expression that requires knowledge of the "state" around it.

Argument 2:

String-literal- A sequence of characters terminated by a trailing '\0' null character. This string is the message the user wants to print to the terminal when the first argument to the macro evaluates to a C-style true.

Example 1