2 .TH macros 3 "13 December 2003" "Straylight/Edgeware" "mLib utilities library"
4 macros \- useful macros
16 .\" @MUFFLE_WARNINGS_DECL
17 .\" @MUFFLE_WARNINGS_EXPR
18 .\" @MUFFLE_WARNINGS_STMT
23 .B "#include <mLib/macros.h>"
25 .BI "size_t N(" array ");"
26 .BI "STR(" tokens\fR... ")"
27 .BI "GLUE(" tokens\fR... ", " tokens\fR... ")"
29 .BI "void DISCARD(" scalar ");"
30 .BI "void IGNORE(" variable ");"
32 .BI "DEPRECATED(" msg ")"
33 .BI "EXECL_LIKE(" ntrail ")"
36 .BI "PRINTF_LIKE(" fmt-index ", " arg-index ")"
37 .BI "SCANF_LIKE(" fmt-index ", " arg-index ")"
39 .BI "MUFFLE_WARNINGS_DECL(" warns ", " decls ")"
40 .BI "MUFFLE_WARNINGS_EXPR(" warns ", " expr ")"
41 .BI "MUFFLE_WARNINGS_STMT(" warns ", " stmt ")"
43 .BI "int GCC_VERSION_P(" maj ", " min ");"
44 .BI "GCC_WARNING(" option ")"
45 .BI "CLANG_WARNING(" option ")"
51 macro returns the number of elements in the named
56 macro expands to a string literal containing the result of expanding its
62 macro expands to a single token, which is the result of gluing together
63 the tokens resulting from expanding its argument token lists. Each of
64 the argument token lists must expand to a single preprocessing token,
65 and the result of gluing these tokens together must be valid
70 macro discards its argument, which must be of some scalar type. This
71 can be useful in muffling warnings about ignoring return codes in cases
72 where you really don't care.
76 macro ignores its argument, which may be an expression of any type.
77 This can be useful in muffling warnings about unused variables.
79 The following annotations can be attached to function declarations and
80 definitions, as part of the declaration specifiers. (Other positions
81 may also work, depending on your compiler, but don't bet on it.) They
82 might not have any effect, depending on your specific compiler.
83 Currently only GCC is well supported, but exactly which features are
84 available depend on the compiler version.
86 Using a function or variable marked as
88 may provoke a compiler warning; this warning may (depending on your
89 compiler version) include the given
92 A variadic function marked as
94 must be called with a null pointer (i.e., an integer constant
95 expression with value 0, cast to
97 in the variadic part of its argument list, followed by
99 further arguments. Typically,
101 is zero. Compilers may warn about misuse of such functions.
103 A function or variable marked as
105 need not be used. This may muffle warnings about leaving the marked
110 must not return. It must have return type
112 This may be useful in muffling warnings about uninitialized variables,
115 A variadic function marked as
119 format argument (in position
121 counting from 1) and a variable-length list of arguments to be formatted
122 (starting from position
124 Compilers may warn about misuse of such functions.
126 A variadic function marked as
130 format argument (in position
132 counting from 1) and a variable-length list of arguments to be formatted
133 (starting from position
135 Compilers may warn about misuse of such functions.
136 .SS Muffling warnings
137 Some compilers allow you to muffle warnings in particular pieces of
138 code. These macros provide a compiler-neutral interface to such
139 facilities. Each macro takes an argument
141 which is a sequence of calls to
142 .IB compiler _WARNING
143 macros listing the warnings to be muffled. The list may contain
144 warnings for several different compilers. The other argument is a
146 consisting of declarations (in the case of
147 .BR MUFFLE_WARNINGS_DECL ),
149 .BR MUFFLE_WARNINGS_EXPR ),
151 .BR MUFFLE_WARNINGS_STMT ).
152 .SS GCC-specific features
155 macro returns a nonzero value if the compiler is at least version
157 of GCC, and zero otherwise. It's useful in preprocessor conditions.
161 macro is intended to be used in
163 lists (see above). It takes a string-literal argument
165 naming a GCC warning option, e.g.,
166 .BR """\-Wdiv-by-zero""" .
170 is similar, except that it works with the Clang compiler.
174 Mark Wooding, <mdw@distorted.org.uk>