Page 1 of 1

Bug with Edge when using ATL

PostPosted: Mar 13, 2007 @ 5:28pm
by gilad_no
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

I think I found a solution

PostPosted: Mar 13, 2007 @ 6:24pm
by gilad_no
ATL overrides StrCpy with StrCpyW. Before including edgemain.h, you need to under StrCpy:

#undef StrCpy

PostPosted: Mar 14, 2007 @ 12:28pm
by edge
Hi Gilad,

Thanks for the fix. We've updated the Edge header files to undefine this symbol.

It's not only StrCpy

PostPosted: Mar 14, 2007 @ 5:39pm
by gilad_no
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

PostPosted: Mar 15, 2007 @ 4:00pm
by edge
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).