N
Nephi Immortal
I created macro in all header and source codes. The TEST condition
must always be true in demo.cpp, but error message displays
Main.obj : error LNK2001: unresolved external symbol "char * _MSG_" (?
_MSG_@@3PADA)
C:\My Projects\RGB\Debug\RGB.exe : fatal error LNK1120: 1 unresolved
externals
It means that main.cpp tries to link char _MSG_, but the definition in
demo.cpp is not found because the TEST condition is set to false.
Why macro does not work?
// Demo.h
#ifdef DEMO_H
#if defined( TEST )
extern char _MSG_[ 256 ];
#else
extern wchar_t _MSG_[ 256 ];
#endif
#endif // DEMO_H
// Demo.cpp
#if defined( TEST )
char _MSG_[ 256 ] = "This is char type.";
#else
wchar_t _MSG_[ 256 ] = L"This is wchar_t type."
#endif
// main.cpp
#define TEST
#include "Demo.h"
int main()
{
#ifdef TEST
char *p = _MSG_;
#else
wchar_t *p = _MSG_;
#endif
}
must always be true in demo.cpp, but error message displays
Main.obj : error LNK2001: unresolved external symbol "char * _MSG_" (?
_MSG_@@3PADA)
C:\My Projects\RGB\Debug\RGB.exe : fatal error LNK1120: 1 unresolved
externals
It means that main.cpp tries to link char _MSG_, but the definition in
demo.cpp is not found because the TEST condition is set to false.
Why macro does not work?
// Demo.h
#ifdef DEMO_H
#if defined( TEST )
extern char _MSG_[ 256 ];
#else
extern wchar_t _MSG_[ 256 ];
#endif
#endif // DEMO_H
// Demo.cpp
#if defined( TEST )
char _MSG_[ 256 ] = "This is char type.";
#else
wchar_t _MSG_[ 256 ] = L"This is wchar_t type."
#endif
// main.cpp
#define TEST
#include "Demo.h"
int main()
{
#ifdef TEST
char *p = _MSG_;
#else
wchar_t *p = _MSG_;
#endif
}