How does the following piece of code work, in other words what is the algorithm of the C preprocessor? Does this work on all compilers?
#include
This simple replacement (first b
with a
and then a
with 170
) should work with any compiler.
You should be careful with more complicated cases (usually involving stringification '#'
and token concatenation '##'
) as there are corner case handled differently at least by MSVC and gcc.
In doubt, you can always check the ISO standard (a draft is available online) to see how things are supposed to work :). Section 6.10.3 is the most relevant in your case.