Macro Question / getting detailed Class / Functioncall Information
-
I have a problem with Macros in Visual C++.:(( I want to write a more Detailed ErrorMessage Class, which gives me a part of sourcecode where the Error occurs. There are some predefined Macros which will help me to that: Current File:
__FILE__
and Current Line:__LINE__
but I did not find a Macro for Current Call.:confused: So I want to make it my self.:omg:#define __CALL__ "void myFunction(int value);"
void myFunction(int value)
{
printf("current Call is %s", __CALL__);
}but problem is that I have to redo this procedure on every Function with additional undef:
#ifdef __CALL__
#undef __CALL__
#endif
#define __CALL__ "void myNextFunction(int value);"So, I want to reduce manual work by autmating the following code:
#ifdef __CALL__
#undef __CALL__
#endif
#define __CALL__ "void myFunction(int value);"so i want to do something like this (multiple Preprocessorcalls in one Macro:
#define SETFUNCTION(x) #ifdef __CALL__ #undef __CALL__ #endif #define __CALL__ x
:wtf: But it all seems not to work or it is a hard handwork to insert this long code before each function. X| So here are my Questions: 1. :confused:Is there any possibility to get easier more detailed Debug Information? (like current Function call) 2. :confused:Is there any way to make a Macro of Macros ? (like #define def(x) #ifndef x #define x #endif) Thank you :rose:,
Sendel
-
I have a problem with Macros in Visual C++.:(( I want to write a more Detailed ErrorMessage Class, which gives me a part of sourcecode where the Error occurs. There are some predefined Macros which will help me to that: Current File:
__FILE__
and Current Line:__LINE__
but I did not find a Macro for Current Call.:confused: So I want to make it my self.:omg:#define __CALL__ "void myFunction(int value);"
void myFunction(int value)
{
printf("current Call is %s", __CALL__);
}but problem is that I have to redo this procedure on every Function with additional undef:
#ifdef __CALL__
#undef __CALL__
#endif
#define __CALL__ "void myNextFunction(int value);"So, I want to reduce manual work by autmating the following code:
#ifdef __CALL__
#undef __CALL__
#endif
#define __CALL__ "void myFunction(int value);"so i want to do something like this (multiple Preprocessorcalls in one Macro:
#define SETFUNCTION(x) #ifdef __CALL__ #undef __CALL__ #endif #define __CALL__ x
:wtf: But it all seems not to work or it is a hard handwork to insert this long code before each function. X| So here are my Questions: 1. :confused:Is there any possibility to get easier more detailed Debug Information? (like current Function call) 2. :confused:Is there any way to make a Macro of Macros ? (like #define def(x) #ifndef x #define x #endif) Thank you :rose:,
Sendel
Putting the macro before the function definition will not work anyway, because the preprocessor will pass through the file first and keep #defining and #undefining SETFUNCTION, and finally SETFUNTION will only be the last function it processed. I thought of a macro like this: #define SETFUNCTION(x) TCHAR __CALL__[] = _T(#x) Put this as the first statement in all your functions, like this for example: void myFunction(int value) { SETFUNCTION(myFunction); ... } and now __CALL__ will simply be a string locally declared within each function. Hope that helps.
-
Putting the macro before the function definition will not work anyway, because the preprocessor will pass through the file first and keep #defining and #undefining SETFUNCTION, and finally SETFUNTION will only be the last function it processed. I thought of a macro like this: #define SETFUNCTION(x) TCHAR __CALL__[] = _T(#x) Put this as the first statement in all your functions, like this for example: void myFunction(int value) { SETFUNCTION(myFunction); ... } and now __CALL__ will simply be a string locally declared within each function. Hope that helps.
Actually, putting the macro before the function may work, I'm not sure. :) Either way, putting a statement at the start of each function seems like a lot of work to me, but I can't think of a better way.