CA2W gave me a “'AtlThrowLastWin32': identifier not found” error

流过昼夜 提交于 2019-12-12 12:18:34

问题


I got a strange 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;
}

The compilation error: error C3861: 'AtlThrowLastWin32': identifier not found

I don't know how this could happen. The document of AtlThrowLastWin32 shows that atldef.h is required, but I couldn't find the declaration of AtlThrowLastWin32 in atldef.h.


回答1:


I finally solved this problem by adding 2 include headers:

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

I don't know why the MSDN document doesn't mention that.



来源:https://stackoverflow.com/questions/1083252/ca2w-gave-me-a-atlthrowlastwin32-identifier-not-found-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!