Monday, August 15, 2011

Microsoft VC++, C99 Standard and __func__ Macro


Apparently, even VC++ 2010 included in Visual Studio 2010 still adheres only to part of the C99 standard. This is really irritating because you have to define different macros if you are debugging your function with the C99 __func__ "predefined" macro.



The list of supported ANSI macros in Visual Studio 2010 can be found at http://msdn.microsoft.com/en-us/library/b0084kay%28v=VS.100%29.aspx.
You will see that in the aforementioned link, Visual Studio 2010 provide an M$-specific macro, i.e. __FUNCTION__ if you want to refer to the current function name in your routine inside that function. It doesn't provide the C99-sanctioned __func__ macro. This would lead to failure during compilation if you try to use the __func__ macro in your code.


On the other hand, GCC supports C99 standard, at least in this particular case (__func__ macro), as shown here.


Post a Comment

No comments: