Start here · Essential guide
How to Stringify a Macro in C++
Learn how the # operator turns a C++ macro argument into a string literal, with examples, the two-level trick for expanded macros and common pitfalls.
Syntax and Functions
How macros work, how to stringify one and why C++ often avoids them.
Start here · Essential guide
Learn how the # operator turns a C++ macro argument into a string literal, with examples, the two-level trick for expanded macros and common pitfalls.
A macro is a name the preprocessor replaces with text before compiling. Learn how #define works in C and C++, with object-like and function-like examples.
A macro processor replaces macro names with their text before compilation. In C and C++, the preprocessor does this job, and you can see its output.
Macros do plain text replacement, with no type checks, scope or namespaces. Learn the common pitfalls and the modern C++ alternatives, with short examples.
Related topics