xref: /freebsd/share/man/man9/CTASSERT.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
10d740fd5SHiten Pandya.\" Copyright (c) 2003 Hiten M. Pandya
20d740fd5SHiten Pandya.\"
30d740fd5SHiten Pandya.\" All rights reserved.
40d740fd5SHiten Pandya.\"
50d740fd5SHiten Pandya.\" This program is free software.
60d740fd5SHiten Pandya.\"
70d740fd5SHiten Pandya.\" Redistribution and use in source and binary forms, with or without
80d740fd5SHiten Pandya.\" modification, are permitted provided that the following conditions
90d740fd5SHiten Pandya.\" are met:
100d740fd5SHiten Pandya.\" 1. Redistributions of source code must retain the above copyright
110d740fd5SHiten Pandya.\"    notice, this list of conditions and the following disclaimer.
120d740fd5SHiten Pandya.\" 2. Redistributions in binary form must reproduce the above copyright
130d740fd5SHiten Pandya.\"    notice, this list of conditions and the following disclaimer in the
140d740fd5SHiten Pandya.\"    documentation and/or other materials provided with the distribution.
150d740fd5SHiten Pandya.\"
160d740fd5SHiten Pandya.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
170d740fd5SHiten Pandya.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
180d740fd5SHiten Pandya.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
190d740fd5SHiten Pandya.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
200d740fd5SHiten Pandya.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
210d740fd5SHiten Pandya.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
220d740fd5SHiten Pandya.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
230d740fd5SHiten Pandya.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
240d740fd5SHiten Pandya.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
250d740fd5SHiten Pandya.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
260d740fd5SHiten Pandya.\"
27*94d919b9SJohn-Mark Gurney.Dd August 1, 2015
280d740fd5SHiten Pandya.Dt CTASSERT 9
29aa12cea2SUlrich Spörlein.Os
300d740fd5SHiten Pandya.Sh NAME
310d740fd5SHiten Pandya.Nm CTASSERT
320d740fd5SHiten Pandya.Nd compile time assertion macro
330d740fd5SHiten Pandya.Sh SYNOPSIS
340d740fd5SHiten Pandya.In sys/param.h
350d740fd5SHiten Pandya.In sys/systm.h
360d740fd5SHiten Pandya.Fn CTASSERT expression
370d740fd5SHiten Pandya.Sh DESCRIPTION
380d740fd5SHiten PandyaThe
393e1cee04SRuslan Ermilov.Fn CTASSERT
40*94d919b9SJohn-Mark Gurneymacro is deprecated and the C11 standard
41*94d919b9SJohn-Mark Gurney.Fn _Static_assert
42*94d919b9SJohn-Mark Gurneyshould be used instead.
43*94d919b9SJohn-Mark GurneyThe header
44*94d919b9SJohn-Mark Gurney.Fa sys/cdefs.h
45*94d919b9SJohn-Mark Gurneyshould be included to provide compatibility for pre-C11 compilers.
46*94d919b9SJohn-Mark Gurney.Pp
47*94d919b9SJohn-Mark GurneyThe
48*94d919b9SJohn-Mark Gurney.Fn CTASSERT
490d740fd5SHiten Pandyamacro evaluates
500d740fd5SHiten Pandya.Fa expression
510d740fd5SHiten Pandyaat compile time and causes a compiler error if it is false.
520d740fd5SHiten Pandya.Pp
530d740fd5SHiten PandyaThe
543e1cee04SRuslan Ermilov.Fn CTASSERT
550d740fd5SHiten Pandyamacro is useful for asserting the size or alignment of important
560d740fd5SHiten Pandyadata structures and variables during compilation, which would
570d740fd5SHiten Pandyaotherwise cause the code to fail at run time.
580d740fd5SHiten Pandya.Sh EXAMPLES
590d740fd5SHiten PandyaAssert that the size of the
600d740fd5SHiten Pandya.Vt uuid
610d740fd5SHiten Pandyastructure is 16 bytes.
623e1cee04SRuslan Ermilov.Pp
633e1cee04SRuslan Ermilov.Dl "CTASSERT(sizeof(struct uuid) == 16);"
640d740fd5SHiten Pandya.Sh SEE ALSO
650d740fd5SHiten Pandya.Xr KASSERT 9
660d740fd5SHiten Pandya.Sh AUTHORS
670d740fd5SHiten PandyaThis manual page was written by
688a7314fcSBaptiste Daroussin.An Hiten M. Pandya Aq Mt hmp@FreeBSD.org .
69