CTASSERT(9) Kernel Developer's Manual CTASSERT(9)

NAME

CTASSERTcompile time assertion macro

SYNOPSIS

void
CTASSERT(expression);

DESCRIPTION

The CTASSERT() macro evaluates expression at compile time and causes a compiler error if it is false.

The CTASSERT() macro is useful for asserting the size or alignment of important data structures and variables during compilation, which would otherwise cause the code to fail at run time.

IMPLEMENTATION NOTES

The CTASSERT() macro should not be used in a header file. It is implemented using a dummy typedef, with a name (based on line number) that may conflict with a CTASSERT() in a source file including that header.

EXAMPLES

Assert that the size of the uuid structure is 16 bytes.

CTASSERT(sizeof(struct uuid) == 16);

SEE ALSO

KASSERT(9)

AUTHORS

This manual page was written by Hiten M. Pandya <hmp@FreeBSD.org>.
January 24, 2010 NetBSD 6.1