1

I am trying to compile an old project that contains a class named CVUtil with a function called StrToInt(char *, int *). This function is called on several locations in the project with the syntax CVUtil::StrToInt(pSomeChar,pSomeInt). When trying to compile this project VisStudio will change StrToInt to StrToIntA since somewhere the file Shlwapi.h is included and in it is the preprocessor statement
"#define StrToInt StrToIntA". I Know that I can avoid this with just changing the name of the function but would like to find out how I can avoid this without doing that. Regards, Arni

4

3 回答 3

1

You could #undef StrToInt in the header that contains the class definition, but the correct way would be to rename the function.

于 2012-09-28T10:05:25.053 回答
0

You can always undefine the previous definition:

#ifdef StrToInt
#undef StrToInt
#endif
#define StrToInt StrToIntA

However a better way would still be to pick another name.

于 2012-09-28T10:05:18.947 回答
-1

您最好调整链接器设置。有关 *A (Ascii) 和 *W (Wide) 函数的详细信息,请参阅http://www.codeproject.com/Articles/76252/What-are-TCHAR-WCHAR-LPSTR-LPWSTR-LPCTSTR-etc。本文介绍了如何调整 Visual Studio 设置。

该指令

#define fun funA

应该由这样的东西来保护:

#ifdef _UNICODE
# define fun funW
#else
# define fun funA
#endif
于 2012-09-28T10:11:23.093 回答