windows - 错误 RC2247 : Symbol name too long (winnt. h)

标签 windows winapi visual-studio-2017

尝试在 Win32 应用程序中显示对话框时出现 RC2247 错误(符号名称太长)。此文件中发生错误:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\winnt.h

这在 VS2015 下运行良好。当我升级到 VS2017 时出现错误。

我看过以下帖子,它们似乎不相关,因为它们属于 prsht.h:

RC2247 : Cannot open Rc file : Resource explorer cannot load resource ; Load failed

http://social.msdn.microsoft.com/Forums/en-US/vcprerelease/thread/4a648d6a-ea81-44d3-89c2-57fa5caa6fd6

如果我注释掉整个 resource.rc 文件,错误就会消失。如果 RC 包含单行,则会发生错误:

#include <winnt.h>

当我点击“编辑代码”时,没有任何反应。

我很感激任何建议。

最佳答案

我们不得将 windows.hwinnt.h 包含到 .rc 文件中 - 此 header - 用于 c/c++ 编译器并且不是为 RC(处理 .rc 文件的资源编译器)设计的。因此,如果我们包含此类文件,我们可能会出错。

我们需要包括#include <winres.h> .rc 文件。此文件专为 RC 编译器设计。在内部它包括:

#include <winuser.rh>
#include <commctrl.rh>
#include <dde.rh>
#include <winnt.rh>
#include <dlgs.h>
#include <winver.h>

并定义一些宏。

我们在 rc 文件中需要/使用的所有标准窗口定义都存在于 winres.h 中(及其子包含)。从另一方面看,windows.h 中不存在额外的符号/定义 - rc 不需要它,有时会导致错误。

很简单#include <winres.h>在资源文件的开头就可以了。

关于windows - 错误 RC2247 : Symbol name too long (winnt. h),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52156649/

相关文章:

c++ - 非分页内存指针

java - 如何修复此 Eclipse 错误?

.net - Windows 服务 - 安装 2 个副本

c++ - 创建只读不可删除文件

c# - 我如何检查用户是否想要动画(通过系统设置)?

c# - 你能从建议中删除一些东西吗?

c++ - C++ 中的 "X does not name a type"错误

c# - 我想通过 SendInput API 发送一些 key

c# - 来自 Visual Studio 2017 的 Azure 函数调试连接出现 'N/A' 监听器连接错误

c# - 系统.反射.TargetException : 'Non-static method requires a target.' only with VS 2017 not with VS 2013