PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Bug with Edge when using ATL

When I'm using Edge under ATL project, I get linking errors:

(When wchar_t is defined as built in type)
Main.obj : error LNK2019: unresolved external symbol "public: static long __cdecl ClassEStd::StrLen(wchar_t const *,unsigned long)" (?StrLen@ClassEStd@@SAJPB_WK@Z) referenced in function "void __cdecl GetPath(wchar_t *)" (?GetPath@@YAXPA_W@Z)
Main.obj : error LNK2019: unresolved external symbol "public: static void __cdecl ClassEStd::StrCpyW(char *,wchar_t const *,long)" (?StrCpyW@ClassEStd@@SAXPADPB_WJ@Z) referenced in function _wWinMain@16
Main.obj : error LNK2019: unresolved external symbol "public: static void __cdecl ClassEStd::StrCpyW(wchar_t *,char const *,long)" (?StrCpyW@ClassEStd@@SAXPA_WPBDJ@Z) referenced in function _wWinMain@16

(Without wchar_t)
Main.obj : error LNK2019: unresolved external symbol "public: static void __cdecl ClassEStd::StrCpyW(char *,unsigned short const *,long)" (?StrCpyW@ClassEStd@@SAXPADPBGJ@Z) referenced in function _wWinMain@16
Main.obj : error LNK2019: unresolved external symbol "public: static void __cdecl ClassEStd::StrCpyW(unsigned short *,char const *,long)" (?StrCpyW@ClassEStd@@SAXPAGPBDJ@Z) referenced in function _wWinMain@16
gilad_no · 13 Mar 2007, 17:24 UTC — I think I found a solution
ATL overrides StrCpy with StrCpyW. Before including edgemain.h, you need to under StrCpy:

#undef StrCpy
Hi Gilad,

Thanks for the fix. We've updated the Edge header files to undefine this symbol.
gilad_no · 14 Mar 2007, 16:39 UTC — It's not only StrCpy
It's related to StrCat/StrTrim as well.

Undef those symbols is just a workaround, since it would break the usage of the real StrCpy/StrCat/StrTrim functions in the application.

I think that you should put those undef in edgemain only when the user defines a specific flag.

#ifdef ATL_WORKAROUND
#undef StrCpy
#undef StrCat
#undef StrTrim
#endif

And to add an entry to the FAQ, for users to add ATL_WORKAROUND when they have the same bug.

The ideal solution would be to modify your functions ClassEStd::StrCpy to something else (Since it conflicts with atlsafe AND with shlwapi definitions).

- Gilad
Hi Gilad,

Thanks for your suggestions.

Unfortunately, we can't change the name of these functions as this would ruin backwards compatibility.

I think adding a check for ATL_WORKAROUND wouldn't work, because in the case it's not defined, an error occurs (so it should always be defined). It would only take additional effort from the developer.

Because these #undefs are used in the edge.h header file, they only take effect when this header file is included (the native ATL functions can be used before including this file).