【问题标题】:error C2065: 'DWORD_PTR' : undeclared identifier错误 C2065:“DWORD_PTR”:未声明的标识符
【发布时间】:2011-04-16 05:44:27
【问题描述】:

编译时

#include "windows.h"
#include "stdafx.h"
#include "resource.h"
#include "ProgressDlg.h"
    ....  
    ...  
rItem.lParam   = (LPARAM)(DWORD_PTR) m_lsStatusMessages.back().c_str();

我收到错误 C2065: 'DWORD_PTR' : undeclared identifier

我是否缺少任何包含。

【问题讨论】:

标签: c++ windows


【解决方案1】:
#include "windows.h"
#include "stdafx.h"

假设您实际使用 MSVC 中的预编译头文件支持,这就是您的问题。您(尝试)在stdafx.h 之前包含windows.h之前 #include "stdafx.h" 的每一行代码都会被忽略。 IIRC MSVC 在某些版本中也给出了一些警告。

#include "windows.h" 放入stdafx.h 或将其移至#include "stdafx.h" 下方。

【讨论】:

    【解决方案2】:

    DWORD_PTRbasetsd.h 中定义,但您应该包含windows.h

    【解决方案3】:

    如果我没记错的话,你至少需要一个定义。 basetsd.h 包含类似

    #if(_WIN32_WINNT >= 0x0400)
    

    #if(WINVER >= 0x0502)
    

    你可以试一试并添加

    #define _WIN32_WINNT 0x0501
    #define WINVER 0x0501
    

    在您添加 windows.h 之前用于 Windows XP 要求设置。

    可以在 here找到预处理器定义和windows头文件的概述。

    【讨论】:

    • 试过了,但有帮助,我使用的是 VC++ 6.0,如果有帮助的话
    • @Subhen:VC6 早于 DWORD_PTR 的引入。您必须手动更新平台 SDK 才能获得它。见这里:stackoverflow.com/questions/2723284
    猜你喜欢
    • 2011-02-15
    • 2011-04-16
    • 2010-12-24
    • 2023-03-04
    • 2011-03-02
    • 2011-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多