当我尝试在 Win32 或 x64 模式下使用 Visual Studio 2010 编译我的 c++ 项目时,我收到以下错误:
>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(135): fatal error C1189: #error : "No Target Architecture"
我的预处理器定义说 WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
是什么导致了这个错误,我该如何解决?
// winnt.h: lines 127-136, MSVS says this is an inactive preprocessor block
#if defined(_WIN64)
#if defined(_AMD64_)
#define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( DWORD )
#elif defined(_IA64_)
#define PROBE_ALIGNMENT( _s ) (TYPE_ALIGNMENT( _s ) > TYPE_ALIGNMENT( DWORD ) ? \
TYPE_ALIGNMENT( _s ) : TYPE_ALIGNMENT( DWORD ))
#else
#error "No Target Architecture"
#endif
更新:我创建了一个新的 msvs 项目并将我的代码复制到其中。我不再有 error : "No Target Architecture"
,但是现在我有一堆涉及 winnt.h 和 winbase.h 的编译错误,并且没有涉及我的任何文件的编译错误。这些文件是否可能已损坏?我需要重新安装 MSVS 2010 吗?
更新 2:所以我缩小了我的问题范围,发现它是 #include <WinDef.h>
这导致了我所有的 winnt.h 编译错误,但我仍然不知道如何解决它。
原文由 philipvr 发布,翻译遵循 CC BY-SA 4.0 许可协议
使用
#include <windows.h>
代替#include <windef.h>
。从
windows.h
维基百科页面:windef.h
是windows.h
自动包含的文件之一。