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