Skip to main content

Practice · 4 of 4

Assertions That Guard Assumptions

CHALLENGE
Difficulty: advanced+25 XP

Implement size_t sizeof_int_ok(void) guarded by a _Static_assert(sizeof(int) >= 4, ...) at file scope (return sizeof(int)), and int version_at_least(int v) returning 1 iff __STDC_VERSION__ (an integer constant) is >= v. The build itself proves the first; the second lets tests interrogate the standard level.

Back to lesson: Practice: Preprocessor Mechanics Drills