W
Whywhat
Hi!
I have a name conflict between my class and windows.h header. The
problem is because of windows.h contains GetMessage macro and my class
a method with the same name. Thus the macro replaces my method
declaration in the main module which contains these lines:
#include <windows.h>
#include "myclass.h"
But in myclass.cpp file windows.h is not included. So I have GetMessage
method compiled and GetMessageA referenced in the main module. Of
course, it causes an 'unresolved external symbol' linker error.
Is there any "good" solution to avoid these uncomfortable error.
Anything instead of renaming (this seems to be the best now for me) my
method, including windows.h into myclass.cpp or so. Can I in some way
disable macro and enable it again?
I guess, smth like that will work, probably:
// myclass.h
#pragma once
#ifdef GetMessage
# undef GetMessage
# define GET_MESSAGE_WAS_DEFINED
#endif
class MyClass
{
...
};
#ifdef GET_MESSAGE_WAS_DEFINED
# undef GET_MESSAGE_WAS_DEFINED
# ifdef _UNICODE
# define GetMessage GetMessageA
# else
# define GetMessage GetMessageW
# endif
#endif
But still, I don't like this solution. It is still is not flexible and
portable (especially if real GetMessage macro definition will change)
And why the hell this global preprocessor definition conflicts with my
class method!!!
I don't like it at all.
Thanks, for any advice about solving the problem.
I have a name conflict between my class and windows.h header. The
problem is because of windows.h contains GetMessage macro and my class
a method with the same name. Thus the macro replaces my method
declaration in the main module which contains these lines:
#include <windows.h>
#include "myclass.h"
But in myclass.cpp file windows.h is not included. So I have GetMessage
method compiled and GetMessageA referenced in the main module. Of
course, it causes an 'unresolved external symbol' linker error.
Is there any "good" solution to avoid these uncomfortable error.
Anything instead of renaming (this seems to be the best now for me) my
method, including windows.h into myclass.cpp or so. Can I in some way
disable macro and enable it again?
I guess, smth like that will work, probably:
// myclass.h
#pragma once
#ifdef GetMessage
# undef GetMessage
# define GET_MESSAGE_WAS_DEFINED
#endif
class MyClass
{
...
};
#ifdef GET_MESSAGE_WAS_DEFINED
# undef GET_MESSAGE_WAS_DEFINED
# ifdef _UNICODE
# define GetMessage GetMessageA
# else
# define GetMessage GetMessageW
# endif
#endif
But still, I don't like this solution. It is still is not flexible and
portable (especially if real GetMessage macro definition will change)
And why the hell this global preprocessor definition conflicts with my
class method!!!
I don't like it at all.
Thanks, for any advice about solving the problem.