Apr 22, 2010 at 6:23pm UTC
Huhu...
I have an member function of my Manager Class named "GetCurrentTime()"...
Also, I have <windows.h> included, which resolves in a problem:
because it includes <winbase.h> itself there is an #define GetTickCount() GetCurrentTime()
...
the problem now is, that i do not want to rename or search-and-replace the GetCurrentTime()-member of my class...
is there another solution? (WIN32_LEAN_AND_MEAN does ofcourse not work)...
Apr 22, 2010 at 7:51pm UTC
this is one of the many reasons why macros are evil.
Anyway you can #undef it:
1 2 3 4 5 6 7 8
#ifdef GetCurrentTime
#undef GetCurrentTime
#endif
class Manager
{
whatever GetCurrentTime(); // now it's OK
};
EDIT:
of course, this will introduce problems if you want to use WinAPI's GetCurrentTime function.
Last edited on Apr 22, 2010 at 7:53pm UTC
Apr 22, 2010 at 9:13pm UTC
i am wondering why this works even while the inclusion of the winbase.h is in another class header file and the undef in this one...
i always did try to do it right in the cpp file which needed the function of mine...
Apr 22, 2010 at 10:53pm UTC
wait.. what? I'm not sure I understand.
It should work as long as you undef after the #include, and before you actually use the function.
Apr 23, 2010 at 2:25pm UTC
I'm not sure that would really work.
If you #include <windows.h> after you #include class.h, windows.h will #define GetCurrentTime again, and all references to it in class.cpp will screw up again.
I would #include class.h after all your other includes