On this page
  1. static_assert
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

static_assert

Prev: assert | Up: assert.h | Next: math.h
Rel: assert.h, _Static_assert
Ref: cppreference — static_assert
Tags: #public #prog #c #stdlib #assert #tier/core


Include

#include <assert.h>

Signature & Overview

static_assert(const_expr, "message");

Compile-time assertion alias for _Static_assert (keyword in C23).

Notes & Pitfalls

Example

#include <assert.h>
#include <limits.h>

static_assert(CHAR_BIT == 8, "Expected 8-bit bytes");

Linked from

Related notes