A question came up on IRC today regarding preprocessor macros and which ones are standard. Amazingly, this MSDN article does a good job of describing the standard macros and lists those non-standard but conventional macros implemented in Visual Studio.
What it doesn't do is mention that some of those macros in fact aren't macros at all, but implicitly defined variables. It goes so far as to mention that compiling with /E
or /EP
parameters (equivalent to g++ -E
or | cpp
, running the preprocessor over source code and doing nothing else) will not expand the 'macros', but it is still very misleading as to why.
This is not valid code so compilation would fail, but after running the preprocessor you get the following output:
This demonstrates that __FUNCTION__
isn't actually a preprocessor macro, but an implicitly defined variable (in fact, a const char*
though this example doesn't show it). __FILE__
and __LINE__
are macros and as such are evaluated by the preprocessor.