BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsla_warning

Macros

#define BSLA_WARNING(x)
 

Detailed Description

Outline

Purpose

Provide a macro to emit a warning when a function is called.

Macros

See also
bsla_annotations

Description

This component provides a macro that indicates that a compiler warning should be emitted when a given function is called.

Macro Reference

BSLA_WARNING(QUOTED_MESSAGE): This annotation, when used, will cause a compile-time warning containing the specified QUOTED_MESSAGE, which must be a string contained in double quotes, when a call to the so-annotated function is not removed through dead-code elimination or other optimizations. While it is possible to leave the function undefined, thus incurring a link-time failure, with the use of this macro the invalid call will be diagnosed earlier (i.e., at compile time), and the diagnostic will include the location of the function call.

BSLA_WARNING_IS_ACTIVE: The macro BSLA_WARNING_IS_ACTIVE is defined if BSLA_WARNING expands to something with the desired effect; otherwise BSLA_WARNING_IS_ACTIVE is not defined and BSLA_WARNING expands to nothing.

Usage

This section illustrates intended use of this component.

Example 1: Function Annotated with BSLA_WARNING

First, we declare and define a function annotated with BSLA_WARNING. Note that the argument to BSLA_WARNING must be a quoted string:

/// Do nothing.
void usageFunc() BSLA_WARNING("Don't call 'usageFunc'");
void usageFunc()
{
}
#define BSLA_WARNING(x)
Definition bsla_warning.h:134

Now, in main, we call usageFunc:

usageFunc();

Finally, observe the following warning issued by the compiler:

.../bsla_warning.t.cpp: In function 'int main(int, char**)':
.../bsla_warning.t.cpp:246:16: warning: call to 'usageFunc' declared with
attribute warning: Don't call 'usageFunc'
usageFunc();
^

Macro Definition Documentation

◆ BSLA_WARNING

#define BSLA_WARNING (   x)