X-Git-Url: https://git.distorted.org.uk/~mdw/mLib/blobdiff_plain/02ce250eda201a9f8a4a5480937238a321e084da..f50c1365107c09453531f01bcaebc3b197c3627f:/utils/macros.3 diff --git a/utils/macros.3 b/utils/macros.3 index a2a9003..98ab238 100644 --- a/utils/macros.3 +++ b/utils/macros.3 @@ -5,6 +5,7 @@ macros \- useful macros .\" @N .\" @STR .\" @GLUE +.\" @STATIC_ASSERT .\" @DISCARD .\" @IGNORE .\" @DEPRECATED @@ -24,6 +25,7 @@ macros \- useful macros .BI "size_t N(" array ");" .BI "STR(" tokens\fR... ")" .BI "GLUE(" tokens\fR... ", " tokens\fR... ")" +.BI "STATIC_ASSERT(" cond ", " msg ");" .BI "void DISCARD(" scalar ");" .BI "void IGNORE(" variable ");" @@ -64,6 +66,18 @@ and the result of gluing these tokens together must be valid preprocessing token. .PP The +.B STATIC_ASSERT +causes compilation to fail if the integer constant expression +.I cond +evaluates to zero. This macro uses the C11 +.B static_assert +declaration if available, and the +.I msg +will be reported in the compiler's diagnostic messsage; otherwise, the macro +falls back to a somewhat ugly hack which currently ignores the +.IR msg . +.PP +The .B DISCARD macro discards its argument, which must be of some scalar type. This can be useful in muffling warnings about ignoring return codes in cases