Quick Links: |
Provide a macro to increment preprocessor numbers. More...
BSLS_MACROINCREMENT(NUMBER) | expand to evaluated NUMBER + 1 |
BSLS_MACROINCREMENT(NUMBER)
, that produces the preprocessor number equal to the number succeeding the supplied argument. This is necessary as the preprocessor performs arithmetic only inside the context of a #if
directive. Common use cases for this macro would be #line
directives or any attempt to provide a computed value when token-pasting to produce an identifier. BSLS_MACROINCREMENT(MACRO_VALUE) Return the preprocessor number that is the successor to 'MACRO_VALUE'. The behavior is undefined unless 'MACRO_VALUE' is an integer literal, or a macro that ultimately expands to an integer literal.
BSLS_MACROINCREMENT
macro to change the effective name of a file without changing the effective line count. cout << "__LINE__, __FILE__: " << __LINE__ << ", " __FILE__ << "\n";
#line
directive: #line BSLS_MACROINCREMENT(__LINE__) "some_other_filename.cpp"
#line
directive is the designated line number of the next line, so we increment current __LINE__
by calling BSLS_MACROINCREMENT
to keep consistent line numbers. #line
directive while the line number still works as expected: cout << "__LINE__, __FILE__: " << __LINE__ << ", " __FILE__ << "\n";