BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bsls_buildtarget.h
Go to the documentation of this file.
1/// @file bsls_buildtarget.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsls_buildtarget.h -*-C++-*-
8#ifndef INCLUDED_BSLS_BUILDTARGET
9#define INCLUDED_BSLS_BUILDTARGET
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bsls_buildtarget bsls_buildtarget
15/// @brief Provide build-target information in object files.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsls
19/// @{
20/// @addtogroup bsls_buildtarget
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsls_buildtarget-purpose"> Purpose</a>
25/// * <a href="#bsls_buildtarget-macros"> Macros </a>
26/// * <a href="#bsls_buildtarget-description"> Description </a>
27/// * <a href="#bsls_buildtarget-compiler-version-check-macro"> Compiler Version Check Macro </a>
28/// * <a href="#bsls_buildtarget-standard-version-inconsistency-check-macro"> Standard Version Inconsistency Check Macro </a>
29/// * <a href="#bsls_buildtarget-deprecation-control-macros"> Deprecation Control Macros </a>
30/// * <a href="#bsls_buildtarget-sanitizer-builds"> Sanitizer Builds </a>
31/// * <a href="#bsls_buildtarget-build-configuration-information"> Build Configuration Information </a>
32/// * <a href="#bsls_buildtarget-optimized-builds-with-debug-information"> Optimized Builds With Debug Information </a>
33/// * <a href="#bsls_buildtarget-usage"> Usage </a>
34///
35/// # Purpose {#bsls_buildtarget-purpose}
36/// Provide build-target information in object files.
37///
38/// # Macros {#bsls_buildtarget-macros}
39///
40/// - BDE_BUILD_TARGET_DBG: flag identifying the presence of debug information
41/// - BDE_BUILD_TARGET_OPT: flag identifying the presence of optimized code
42/// - BDE_BUILD_TARGET_EXC: flag identifying exception-enabled builds
43/// - BDE_BUILD_TARGET_MT: flag identifying multi-threaded builds (deprecated)
44/// - BDE_BUILD_TARGET_32: flag identifying 32-bit builds
45/// - BDE_BUILD_TARGET_64: flag identifying 64-bit builds
46/// - BDE_BUILD_TARGET_ASAN: flag identifying address sanitizer builds
47/// - BDE_BUILD_TARGET_MSAN: flag identifying memory sanitizer builds
48/// - BDE_BUILD_TARGET_OPT: flag identifying an optimized build
49/// - BDE_BUILD_TARGET_SAFE: flag identifying SAFE level assert check builds
50/// - BDE_BUILD_TARGET_SAFE_2: flag identifying SAFE_2 level assert check builds
51/// - BDE_BUILD_TARGET_TSAN: flag identifying thread sanitizer builds
52/// - BDE_BUILD_TARGET_UBSAN: flag identifying UB sanitizer builds
53/// - BDE_BUILD_SKIP_VERSION_CHECKS: turn off compiler version checks
54/// - BDE_DONT_ALLOW_TRANSITIVE_INCLUDES: remove unused #includes from headers
55/// - BDE_OMIT_DEPRECATED: legacy flag to deprecate a block of code
56/// - BDE_OMIT_INTERNAL_DEPRECATED: legacy flag to deprecate internal-only code
57/// - BDE_OPENSOURCE_PUBLICATION: marker for non-deprecated internal-only code
58///
59/// @see bsls_deprecate, bsls_assert, bsls_review
60///
61/// # Description {#bsls_buildtarget-description}
62/// The purpose of this component is to cause a link-time error
63/// when trying to link an executable with incompatible libraries. This
64/// component defines type names that indicate two build target parameters.
65/// These parameters determine whether the build was exception-enabled (which is
66/// the case unless overridden by defining the `BDE_BUILD_TARGET_NO_EXC` macro).
67/// The types defined by this component should not be used directly. This
68/// component also documents macros that can be used to disable checks that are
69/// performed elsewhere. Note that the deprecated macro `BDE_BUILD_TARGET_MT`
70/// is always defined for historical reasons where it was used to detect that
71/// a build supported multiple threads; there is no option to disable support
72/// for threading in BDE.
73///
74/// ## Compiler Version Check Macro {#bsls_buildtarget-compiler-version-check-macro}
75///
76///
77/// By design, programs using BDE fail to build if support for a C++ standard
78/// version is requested but the compiler's support for that standard is not
79/// sufficiently stable (possibly causing issues at runtime that are very
80/// difficult to debug). We provide the macro `BDE_BUILD_SKIP_VERSION_CHECKS`
81/// to disable these checks for the purpose of testing and experimenting with
82/// different compiler configurations. This macro should **not** be defined for
83/// integrated production builds such as dpkg, as doing so may result in
84/// unstable code being deployed to production.
85///
86/// ## Standard Version Inconsistency Check Macro {#bsls_buildtarget-standard-version-inconsistency-check-macro}
87///
88///
89/// C++ object files built using a particular standard version must be linked
90/// with BDE libraries built using the same standard version, or else the
91/// program will be ill formed, no diagnostic required (IFNDR) and may exhibit
92/// issues at runtime that are very difficult to debug.
93///
94/// ## Deprecation Control Macros {#bsls_buildtarget-deprecation-control-macros}
95///
96///
97/// In addition to the `BDE_BUILD_TARGET_*` macros that determine the link-time
98/// compatibility of different libraries built on BDE, this component documents
99/// a macro that determines whether deprecated interfaces are available to
100/// programs built on BDE:
101///
102/// `BDE_OMIT_DEPRECATED`:
103/// This macro, if defined, indicates that all code deprecated before BDE
104/// 3.2 will be either omitted from a build of the library (if the code has
105/// not been updated to use @ref bsls_deprecate ), or identified to the
106/// compiler as deprecated (if the code has been updated to use
107/// @ref bsls_deprecate ). New uses of this macro are not supported; use
108/// @ref bsls_deprecate instead.
109///
110/// In addition to `BDE_OMIT_DEPRECATED`, there are two other macros that also
111/// determine whether deprecated interfaces are available to programs built on
112/// BDE:
113///
114/// `BDE_OMIT_INTERNAL_DEPRECATED`:
115/// This macro, if defined, indicates that all internal-only code
116/// deprecated before BDE 3.2 will be either omitted from a build of the
117/// library (if the code has not been updated to use @ref bsls_deprecate ), or
118/// identified to the compiler as deprecated (if the code has been updated
119/// to use @ref bsls_deprecate ). This category consists almost entirely of
120/// code that was already deprecated at the time of a component's initial
121/// release to open-source. New uses of this macro are not supported; use
122/// @ref bsls_deprecate instead.
123///
124/// `BDE_OPENSOURCE_PUBLICATION`:
125/// This macro marks code that is not deprecated, but is nevertheless
126/// excluded from the open-source release of BDE. This category consists
127/// primarily of code that exists to support STLPort containers, which were
128/// not included in the open-source release, or that documents backward
129/// compatibility access to the package-prefix versions of non-deprecated
130/// symbols in BSL. `BDE_OPENSOURCE_PUBLICATION` exists for purposes of
131/// documentation only, and should not be defined for any build of the
132/// library. In particular, there is no guarantee that the library will
133/// build or will function correctly if `BDE_OPENSOURCE_PUBLICATION` is
134/// defined.
135///
136/// Together with `BDE_OMIT_DEPRECATED`, these macros divide the BDE codebase
137/// into four categories:
138/// @code
139/// +-----------------------------------------+------------------------------+
140/// | CATEGORY | LABEL |
141/// +=========================================+==============================+
142/// | universally distributed code | no label |
143/// +-----------------------------------------+------------------------------+
144/// | Bloomberg-only code | BDE_OPENSOURCE_PUBLICATION |
145/// +-----------------------------------------+------------------------------+
146/// | universally distributed code deprecated | BDE_OMIT_DEPRECATED |
147/// | before BDE 3.2 | |
148/// +-----------------------------------------+------------------------------+
149/// | Bloomberg-only code deprecated before | BDE_OMIT_INTERNAL_DEPRECATED |
150/// | BDE 3.2 | |
151/// +-----------------------------------------+------------------------------+
152/// @endcode
153/// By default, all code in BDE is both current and universally distributed.
154/// All code that is deprecated, excluded from our open-source distribution, or
155/// both, is surrounded with conditional compilation macros to allow test builds
156/// without that code, and/or to make it easy to prepare an open-source
157/// distribution from the full internal BDE codebase. The conditional
158/// compilation macros are:
159///
160/// ## Sanitizer Builds {#bsls_buildtarget-sanitizer-builds}
161///
162///
163/// There a flag set by the BDE build system to indicate when a build has a
164/// given sanitizer enabled:
165///
166/// `BDE_BUILD_TARGET_ASAN`:
167/// This macro, when defined, indicates that the current build mode
168/// includes address sanitizer.
169///
170/// `BDE_BUILD_TARGET_MSAN`:
171/// This macro, when defined, indicates that the current build mode
172/// includes memory sanitizer.
173///
174/// `BDE_BUILD_TARGET_TSAN`:
175/// This macro, when defined, indicates that the current build mode
176/// includes thread sanitizer.
177///
178/// `BDE_BUILD_TARGET_UBSAN`:
179/// This macro, when defined, indicates that the current build mode
180/// includes undefined behavior sanitizer.
181///
182/// Preprocessor conditionals on these macros are sometimes necessary when
183/// certain types of tests are incompatible with a given sanitizer, but
184/// their use should be rare, carefully considered, and appear only in test
185/// drivers.
186///
187///
188/// ## Build Configuration Information {#bsls_buildtarget-build-configuration-information}
189///
190///
191/// Several other macros that are defined, or not, to provide information about
192/// the build target that code might want to adjust for during translation.
193///
194/// `BDE_BUILD_TARGET_32`:
195/// This macro, when defined, indicates that the current build target will
196/// emit instructions for 32-bit architectures.
197///
198/// `BDE_BUILD_TARGET_64`:
199/// This macro, when defined, indicates that the current build target will
200/// emit instructions for 64-bit architectures.
201///
202/// `BDE_BUILD_TARGET_OPT`:
203/// This macro, when defined, indicates that the current build target will
204/// aggressively optimize code, potentially to the detriment of debug
205/// support. Undefined behavior is more likely to demonstrate adverse
206/// consequences that support better optimization. By default only `OPT`
207/// assertions will be evaluated --- see @ref bsls_assert and @ref bsls_review
208/// for more details.
209///
210/// `BDE_BUILD_TARGET_SAFE`:
211/// This macro, when defined, indicates that the current build target will
212/// enable `SAFE` assertions --- see @ref bsls_assert and @ref bsls_review for
213/// more details.
214///
215/// `BDE_BUILD_TARGET_SAFE_2`:
216/// This macro, when defined, indicates that the current build target will
217/// enable `SAFE_2` assertions --- see @ref bsls_assert and @ref bsls_review for
218/// more details.
219///
220/// `BDE_DONT_ALLOW_TRANSITIVE_INCLUDES`:
221/// This macro, when defined, indicates that the current build target will
222/// exclude `#include` directives that have been marked as present only to
223/// support higher level code that depended implicitly on that `#include`
224/// this is no longer necessary to compile the component itself. Note
225/// that attempts to define this macro on the command line passed to the
226/// compiler will be ignored, and the macro to force this definition,
227/// `BDE_FORCE_DONT_ALLOW_TRANSITIVE_INCLUDES`, should be defined instead.
228/// See @ref bsls_ident for more details where the consistency rules regarding
229/// these macros are enforced.
230///
231/// ## Optimized Builds With Debug Information {#bsls_buildtarget-optimized-builds-with-debug-information}
232///
233///
234/// Both macros `BDE_BUILD_TARGET_OPT` and `BDE_BUILD_TARGET_DBG` are defined
235/// when the build configuration includes optimization and debug flags (for
236/// example, `opt_dbg` UFID or `RelWithDebInfo` CMake build type).
237///
238/// ## Usage {#bsls_buildtarget-usage}
239///
240///
241/// There is no usage example for this component since it is not meant for
242/// direct client use.
243/// @}
244/** @} */
245/** @} */
246
247/** @addtogroup bsl
248 * @{
249 */
250/** @addtogroup bsls
251 * @{
252 */
253/** @addtogroup bsls_buildtarget
254 * @{
255 */
256
257#include <bsls_linkcoercion.h>
258
259
260
261// ============================================================================
262// BDE_BUILD_TARGET_EXC/BDE_BUILD_TARGET_NO_EXC
263// ============================================================================
264
265// Default to an exception-enabled build unless 'BDE_BUILD_TARGET_NO_EXC' is
266// defined.
267
268#if !defined(BDE_BUILD_TARGET_NO_EXC) && !defined(BDE_BUILD_TARGET_EXC)
269# define BDE_BUILD_TARGET_EXC
270#elif defined(BDE_BUILD_TARGET_NO_EXC) && defined(BDE_BUILD_TARGET_EXC)
271# error Do not define both `BDE_BUILD_TARGET_EXC` and `BDE_BUILD_TARGET_NO_EXC`
272#endif
273
274#if defined(BDE_BUILD_TARGET_EXC)
275namespace bsls {
276
278 static const int s_isBuildTargetExc;
279};
281
282} // close package namespace
283#else
284namespace bsls {
285
286struct BuildTargetExcNo {
287 static const int s_isBuildTargetExc;
288};
289typedef BuildTargetExcNo BuildTargetExc;
290
291} // close package namespace
292#endif
293
295 const int,
296 bsls_buildtarget_coerce_exc,
298
299// ============================================================================
300// BDE_BUILD_TARGET_MT
301// ============================================================================
302
303// Always define `BDE_BUILD_TARGET_MT` to indicate multithreaded support.
304
305#ifndef BDE_BUILD_TARGET_MT
306# define BDE_BUILD_TARGET_MT
307#endif
308
309
310
311#endif
312
313// ----------------------------------------------------------------------------
314// Copyright 2013 Bloomberg Finance L.P.
315//
316// Licensed under the Apache License, Version 2.0 (the "License");
317// you may not use this file except in compliance with the License.
318// You may obtain a copy of the License at
319//
320// http://www.apache.org/licenses/LICENSE-2.0
321//
322// Unless required by applicable law or agreed to in writing, software
323// distributed under the License is distributed on an "AS IS" BASIS,
324// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
325// See the License for the specific language governing permissions and
326// limitations under the License.
327// ----------------------------- END-OF-FILE ----------------------------------
328
329/** @} */
330/** @} */
331/** @} */
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY(type, refName, referredSymbol)
Definition bsls_linkcoercion.h:203
Definition bdlt_iso8601util.h:707
BuildTargetExcYes BuildTargetExc
Definition bsls_buildtarget.h:280
Definition bsls_buildtarget.h:277
static const int s_isBuildTargetExc
Definition bsls_buildtarget.h:278