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