You can paste the code in VS2005 in a new .cpp file and see that Visual Assist X will get confused in parenthesis matching when the return_bool macro is used. VA does not get confused with the ## operator.
The macro that I provided you does not make any sense in this context and I will try to explain it and make it simpler. This is also the code that you can use to test the bug:
#define return_bool return (bool
//declares a function that returns bool by casting NULL to bool
//also defines the beginning of a static function that takes
//as argument a pointer to a SomeObject object and the argument name is object
//the problem is only in the some_return_bool) part were
//the macro should expand to return (bool) but it gets confused
#define SomeMacro() \ bool function_bool() {return_bool)1;} \ static bool staticFunction(SomeObject *object)
struct SomeObject
{
void someFunction()
};
SomeMacro()
{
//click someFunction to test
//will not work when macro defined with return_bool
//and will work if defined with return(bool instead
object->someFunction();
}
and all of this will expand to:
struct SomeObject
{
void someFunction()
};
bool function_bool()
{
return(bool)1;
};
static bool staticFunction(SomeObject *object)
{
object->someFunction();
}
If you paste this code in VS2005, it will show the behavior.
Paste the code and then click over someFunction, symbols will not work.
If you then replace return_bool by return (bool, the definition of someFunction will show in the definition field next to the context field. The problem is exactly the expansion of return_bool.
The actual macro in the engine is used to generate static functions that return specific types. Here I used bool in the example, but the functions can get generated with bool, void, int, const char *.
The actual code looks like the following:
#define conmethod_return_const return (const
#define conmethod_return_S32 return (S32
#define conmethod_return_F32 return (F32
#define conmethod_nullify(val)
#define conmethod_return_void conmethod_nullify(void
#define conmethod_return_bool return (bool
# define ConsoleMethod(className,name,returnType,minArgs,maxArgs,usage1) \ static inline returnType c##className##name(className *, S32, const char **argv); \ static returnType c##className##name##caster(SimObject *object, S32 argc, const char **argv) { \ AssertFatal( dynamic_cast<className*>( object ), "Object passed to " #name " is not a " #className "!" ); \ return (returnType) c##className##name(static_cast<className*>(object),argc,argv); \ }; \ static ConsoleConstructor className##name##obj(#className,#name,c##className##name##caster,usage1,minArgs,maxArgs); \ static inline returnType c##className##name(className *object, S32 argc, const char **argv)
and it is used about 1000 times like this:
ConsoleMethod( MyObject, rebuild, bool, 2, 2, "()")
{
object->rebuild();
}
I will look into stdafx.h.
Thank you.