BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsla.h
Go to the documentation of this file.
1/// @file bsla.h
2///
3///
4/// @defgroup bsla Package bsla
5/// @brief Basic Standard Library Annotations (bsla)
6/// @addtogroup bsl
7/// @{
8/// @addtogroup bsla
9/// [bsla]: group__bsla.html
10/// @{
11///
12/// # Purpose {#bsla-purpose}
13/// Provide macros for portable use of compiler annotations.
14///
15/// # Mnemonic {#bsla-mnemonic}
16/// Basic Standard Library Annotations (bsla)
17///
18/// # Description {#bsla-description}
19/// The 'bsla' package provides a variety of macros that expand to
20/// annotations to provide hints to the compiler, to suppress or emit compiler
21/// warnings or errors.
22///
23/// The annotations themselves are not supported on all compilers, and sometimes
24/// different annotations are required for different compilers to have a given
25/// effect. The macros provided in this package either expand to the correct
26/// annotation for the current compiler, or, if the compiler does not support any
27/// form of the given annotation, the macros expand to nothing.
28///
29/// For every macro, 'BSLA_{X}', there is a corresponding macro,
30/// 'BSLA_{X}_IS_ACTIVE', which is always defined to an integer, and expands to 0
31/// if 'BSLA_{X}' expands to nothing and 1 if 'BSLA_{X}' expands to an annotation
32/// and the annotation works. There are situations where compilers will
33/// "tolerate" an annotation -- the annotation won't be reported as a syntax
34/// error, but it will have no effect. In those cases, 'BSLA_{X}' will expand to
35/// nothing and 'BSLA_{X}_IS_ACTIVE' will be 0.
36///
37/// ## Hierarchical Synopsis
38///
39/// The 'bsla' package currently has 16 components having 3 levels of physical
40/// dependency. The list below shows the hierarchical ordering of the components.
41/// The order of components within each level is not architecturally significant,
42/// just alphabetical.
43/// @code
44/// 3. bsla_annotations
45///
46/// 2. bsla_used
47///
48/// 1. bsla_deprecated
49/// bsla_error
50/// bsla_fallthrough
51/// bsla_format
52/// bsla_maybeunused
53/// bsla_nodiscard
54/// bsla_nonnullarg
55/// bsla_noreturn
56/// bsla_nullterminated
57/// bsla_printf
58/// bsla_scanf
59/// bsla_unreachable
60/// bsla_unused !DEPRECATED!
61/// bsla_warning
62/// @endcode
63///
64/// ## Component Synopsis
65///
66/// @ref bsla_annotations :
67/// Provide support for compiler annotations for compile-time safety.
68///
69/// @ref bsla_deprecated :
70/// Provide compiler-hint macros to indicate deprecated entities.
71///
72/// @ref bsla_error :
73/// Provide a macro to emit an error message when a function is called.
74///
75/// @ref bsla_fallthrough :
76/// Provide a macro to suppress warnings on `switch` fall-throughs.
77///
78/// @ref bsla_format :
79/// Provide a macro to indicate that a return value is a format string.
80///
81/// @ref bsla_maybeunused :
82/// Provide a macro to suppress "unused" warnings.
83///
84/// @ref bsla_nodiscard :
85/// Provide a macro for warning about ignored function results.
86///
87/// @ref bsla_nonnullarg :
88/// Provide macros to hint at null arguments to functions.
89///
90/// @ref bsla_noreturn :
91/// Provide a macro to issue a compiler warning if a function returns.
92///
93/// @ref bsla_nullterminated :
94/// Provide macros for use with `NULL`-terminated variadic functions.
95///
96/// @ref bsla_printf :
97/// Provide a macro to indicate `printf`-style arguments.
98///
99/// @ref bsla_scanf :
100/// Provide a macro for checking `scanf`-style format strings.
101///
102/// @ref bsla_unreachable :
103/// Provide a compiler-hint macro to indicate unreachable code.
104///
105/// @ref bsla_unused : !DEPRECATED!
106/// Provide a macro to suppress "unused" warnings.
107///
108/// @ref bsla_used :
109/// Provide a macro to prevent elision of unused entities.
110///
111/// @ref bsla_warning :
112/// Provide a macro to emit a warning when a function is called.
113///
114/// ## Component Overview
115///
116/// This section provides a brief introduction to some of the components in the
117/// 'bsla' package. See the documentation in each component for full details.
118///
119/// ### @ref bsla_annotations
120///
121/// This component exists to provide a single component whose header can be
122/// included to transitively include all of the annotation macros defined in the
123/// 'bsla' package. The macros that are transitively included by this component
124/// correspond to various compiler features, and can be used to annotate code for
125/// specific compile-time safety checks.
126///
127/// ### @ref bsla_deprecated
128///
129/// This component provides a preprocessor macro that hints to the compile that a
130/// function, variable, or type is deprecated.
131///
132/// ### @ref bsla_error
133///
134/// This component provides a preprocessor macro that flags a function such that a
135/// compiler error will occur when the function is called. On platforms where the
136/// appropriate attribute is not supported, the macro expands to nothing.
137///
138/// ### @ref bsla_fallthrough
139///
140/// This component provides a preprocessor macro that suppresses compiler warnings
141/// about flow of control fall-through from one 'case' or 'default' of a 'switch'
142/// statement to another. On compilers where the appropriate attribute is not
143/// supported, the macro expands to nothing.
144///
145/// ### @ref bsla_format
146///
147/// This component provides a preprocessor macro to indicate that an indexed
148/// argument of a function is a 'printf'-style format specification, and that the
149/// function will return a 'printf'-style format string with an equivalent
150/// specification.
151///
152/// ### @ref bsla_maybeunused
153///
154/// This component provides a preprocessor macro that will suppress "unused"
155/// warnings on a locally defined function, type, or variable that is not used.
156///
157/// ### @ref bsla_nodiscard
158///
159/// This component provides a preprocessor macro that annotates a function such
160/// that a compiler warning will be generated if the return value of the function
161/// is ignored.
162///
163/// ### @ref bsla_nonnullarg
164///
165/// This component provides preprocessor macros that define compiler-specific
166/// compile-time annotations. These macros instruct the compiler to warn if null
167/// is passed to certain arguments to a function, or, on platforms where the
168/// feature is not supported, expand to nothing.
169///
170/// ### @ref bsla_noreturn
171///
172/// This component provides a preprocessor macro that annotates a function as
173/// never returning, resulting in a compiler warning if a path of control exists
174/// such that the function does return.
175///
176/// ### @ref bsla_nullterminated
177///
178/// This component provides preprocessor macros to indicate that a variadic
179/// function's arguments are terminated by a 'NULL' value, or, in the case of
180/// 'BSLA_NULLTERMINATEDAT', by a 'NULL' value at a certain index. Note that the
181/// terminating 'NULL' must actually be 'NULL'; passing 0 in it's place will
182/// result in a warning.
183///
184/// ### @ref bsla_printf
185///
186/// This component provides a preprocessor macro that allows the designation of a
187/// given function argument as a 'printf'-style format string, and arguments
188/// starting at a certain index in the argument list to be formatted according to
189/// that string.
190///
191/// ### @ref bsla_scanf
192///
193/// This component provides a preprocessor macro that indicates that one of the
194/// arguments to a function is a 'scanf'-style format string, and that the
195/// arguments starting at a certain index are to be checked for compatibility with
196/// that format string.
197///
198/// ### @ref bsla_unreachable
199///
200/// This component provides a preprocessor macro that hints to the compile that a
201/// statement in the code is intended to be unreachable.
202///
203/// ### @ref bsla_unused
204///
205/// This component provides a preprocessor macro that will suppress "unused"
206/// warnings on a locally defined function, type, or variable that is not used.
207///
208/// ### @ref bsla_used
209///
210/// This component provides a preprocessor macro that will guarantee the emission
211/// of a local function, type, or variable whether it is used or not.
212///
213/// ### @ref bsla_warning
214///
215/// This component provides a macro that indicates that a compiler warning should
216/// be emitted when a given function is called.
217///
218/// @}
219/** @} */