xref: /freebsd/share/man/man9/CTASSERT.9 (revision 7899f917b1c0ea178f1d2be0cfb452086d079d23)
1.\" Copyright (c) 2003 Hiten M. Pandya
2.\"
3.\" All rights reserved.
4.\"
5.\" This program is free software.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26.\"
27.Dd August 1, 2015
28.Dt CTASSERT 9
29.Os
30.Sh NAME
31.Nm CTASSERT
32.Nd compile time assertion macro
33.Sh SYNOPSIS
34.In sys/param.h
35.In sys/systm.h
36.Fn CTASSERT expression
37.Sh DESCRIPTION
38The
39.Fn CTASSERT
40macro is deprecated and the C11 standard
41.Fn _Static_assert
42should be used instead.
43The header
44.Fa sys/cdefs.h
45should be included to provide compatibility for pre-C11 compilers.
46.Pp
47The
48.Fn CTASSERT
49macro evaluates
50.Fa expression
51at compile time and causes a compiler error if it is false.
52.Pp
53The
54.Fn CTASSERT
55macro is useful for asserting the size or alignment of important
56data structures and variables during compilation, which would
57otherwise cause the code to fail at run time.
58.Sh EXAMPLES
59Assert that the size of the
60.Vt uuid
61structure is 16 bytes.
62.Pp
63.Dl "CTASSERT(sizeof(struct uuid) == 16);"
64.Sh SEE ALSO
65.Xr KASSERT 9
66.Sh AUTHORS
67This manual page was written by
68.An Hiten M. Pandya Aq Mt hmp@FreeBSD.org .
69