Index: share/man/man3/assert.3 =================================================================== --- share/man/man3/assert.3 +++ share/man/man3/assert.3 @@ -28,15 +28,18 @@ .\" @(#)assert.3 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd May 31, 2018 +.Dd April 19, 2021 .Dt ASSERT 3 .Os .Sh NAME -.Nm assert +.Nm assert , +.Nm static_assert .Nd expression verification macro .Sh SYNOPSIS .In assert.h .Fn assert expression +.Fn static_assert expression +.Fn static_assert expression message .Sh DESCRIPTION The .Fn assert @@ -81,6 +84,21 @@ macro should only be used for ensuring the developer's expectations hold true. It is not appropriate for regular run-time error detection. +.Pp +The +.Fn static_assert +macro expands to +.Fn _Static_assert , +and contrarily to +.Fn assert , +makes assertions at compile-time. +Once the constraint is violated, the compiler produces a diagnostic +message including the string literal message, if provided. +The initial form of the +.Fn _Static_assert +containing a string literal message was introduced in C11 standard, and +the other form with no string literal is to be implemented by C2x and +your compiler may lack its adoption at present. .Sh EXAMPLES The assertion: .Dl "assert(1 == 0);" @@ -99,10 +117,19 @@ .Xr abort2 2 , .Xr abort 3 .Sh STANDARDS +.Rs The .Fn assert macro conforms to .St -isoC-99 . +.Re +.Pp +.Rs +The +.Fn static_assert +macro conforms to +.St -isoC-2011 . +.Re .Sh HISTORY An .Nm