Quick Links:

bal | bbl | bdl | bsl

Defines

Component bsls_linkcoercion
[Package bsls]

Provide a way to force a link-time dependency into an object. More...

Defines

#define BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY(type,refName,referredSymbol)

Detailed Description

Outline
Purpose:
Provide a way to force a link-time dependency into an object.
Macros:
BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY
Description:
This component provides a facility to force a link-time dependency on a symbol of the name supplied to the macro into the translation unit being compiled. This macro can be useful for generating link-time failures if a library version mismatch occurs.
Macro Summary:
This section provides a brief description of the macros defined in this component.
   BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY
       This macro forces a link-time dependency into an object.
Usage:
In this section we show intended use of this component.
Example 1: Force a Link-Time Dependency on s_coerce:
First, declare a variable s_coerce of type const char *:
  extern const char *s_coerce;
Then, use BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY to add a dependency on this symbol into any object which includes the header:
  BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY(const char *,
                                            bsls_coerceexample_coerce,
                                            s_coerce)
Finally, in the corresponding .cpp file, the s_coerce symbol needs to be defined:
  const char *s_coerce = "Link me in!";

Define Documentation

#define BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY (   type,
  refName,
  referredSymbol 
)
Value:
namespace {                                                     \
        extern type *const refName = &referredSymbol;               \
    }