/ Published in: C++
Article explains why STRINGIFY and TOSTRING are both needed.
This technique is useful for embedded apps to print debug strings to a debug console. ASSERT or TRACE statements can incorporate these macros. The line numbers are converted to strings at compile-time rather than run-time.
This technique is useful for embedded apps to print debug strings to a debug console. ASSERT or TRACE statements can incorporate these macros. The line numbers are converted to strings at compile-time rather than run-time.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) #define AT __FILE__ ":" TOSTRING(__LINE__) printf( AT " message"); // Expect output like: "snipplr.c:5 message"
URL: http://www.decompile.com/cpp/faq/file_and_line_error_string.htm