CA2W gave me the error "AtlThrowLastWin32: ID not found"

I had a weird compilation error when I followed the MSDN document to use CA2W to convert big5 strings to unicode strings in Visual Studio 2005.

This is the code I wrote:

#include <string> #include <atldef.h> #include <atlconv.h> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { string chineseInBig5 = "\xA4\xA4\xA4\xE5"; ATL::CA2W(chineseInBig5.c_str()); return 0; } 

Compilation error: error C3861: "AtlThrowLastWin32": identifier not found

I do not know how this could happen. the AtlThrowLastWin32 document shows that atldef.h is required, but I could not find the AtlThrowLastWin32 declaration in atldef.h.

+4
source share
1 answer

I finally solved this problem by adding 2 headers:

 #include <atlbase.h> #include <atlstr.h> 

I do not know why this is not mentioned in the MSDN document.

+7
source

All Articles