名前空間
変種
操作

static_assert

提供: cppreference.com
< c‎ | error
ヘッダ <assert.h> で定義
#define static_assert _Static_assert

この便利マクロはキーワード _Static_assert に展開されます。

[編集]

#include <assert.h>
int main(void)
{
    static_assert(2 + 2 == 4, "2+2 isn't 4");      // well-formed
    static_assert(sizeof(int) < sizeof(char),
                 "this program requires that int is less than char"); // compile-time error
}