debian/.gitignore: Ignore generated `lib2-adns.install' file.
[mLib] / utils / macros.3
index bd4145a..98ab238 100644 (file)
@@ -5,6 +5,7 @@ macros \- useful macros
 .\" @N
 .\" @STR
 .\" @GLUE
+.\" @STATIC_ASSERT
 .\" @DISCARD
 .\" @IGNORE
 .\" @DEPRECATED
@@ -16,7 +17,6 @@ macros \- useful macros
 .\" @MUFFLE_WARNINGS_DECL
 .\" @MUFFLE_WARNINGS_EXPR
 .\" @MUFFLE_WARNINGS_STMT
-.\" @GCC_VERSION_P
 .\" @GCC_WARNING
 .SH SYNOPSIS
 .nf
@@ -25,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 ");"
@@ -40,8 +41,8 @@ macros \- useful macros
 .BI "MUFFLE_WARNINGS_EXPR(" warns ", " expr ")"
 .BI "MUFFLE_WARNINGS_STMT(" warns ", " stmt ")"
 
-.BI "int GCC_VERSION_P(" maj ", " min ");"
 .BI "GCC_WARNING(" option ")"
+.BI "CLANG_WARNING(" option ")"
 .fi
 .SH DESCRIPTION
 .SS Utilities
@@ -65,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
@@ -163,7 +176,19 @@ lists (see above).  It takes a string-literal argument
 .I option
 naming a GCC warning option, e.g.,
 .BR """\-Wdiv-by-zero""" .
+.PP
+The
+.B CLANG_WARNING
+is similar, except that it works with the Clang compiler.
+.PP
+Note that including
+.B <mLib/macros.h>
+also defines the compiler-test macros in
+.BR <mLib/compiler.h>;
+see
+.BR compiler (3).
 .SH "SEE ALSO"
-.BR mLib (3).
+.BR mLib (3),
+.BR compiler (3).
 .SH "AUTHOR"
 Mark Wooding, <mdw@distorted.org.uk>