Quick Links: |
Provide a macro to emit a warning when a function is called. More...
BSLA_WARNING(QUOTED_MESSAGE) | emit warning message during compilation |
BSLA_WARNING_IS_ACTIVE | 0 if BSLA_WARNING expands to nothing, else 1 |
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 to 0 if BSLA_WARNING
expands to nothing and 1 otherwise.BSLA_WARNING
. Note that the argument to BSLA_WARNING
must be a quoted string: void usageFunc() BSLA_WARNING("Don't call 'usageFunc'"); // Do nothing. void usageFunc() { }
main
, we call usageFunc
: usageFunc();
.../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(); ^