【问题标题】:winnt.h errors on VS Command PromptVS 命令提示符上的 winnt.h 错误
【发布时间】:2011-08-21 23:12:25
【问题描述】:

我正在尝试使用 NIXYSA (http://code.google.com/p/nixysa/) 开发一个 NPAPI 插件,该插件使用 Scons 来构建项目。现在我只是在尝试构建 Hello World 示例应用程序。 问题是,在生成 C 源文件后,编译时会遇到奇怪的 winnt.h 错误。 下面是它使用的命令和结果:

c:\Users\Mo\Documents\Projects\Chrome Plugin\nixysa-read-only\examples\hel
lo_world>"c:\Program Files (x86)\Microsoft Visual Studio 9.0\vc\bin\cl" /Foglue\
globals_glue.obj /c glue\globals_glue.cc /TP /nologo /DWIN32 /DOS_WINDOWS /I. /I
 "C:\Users\Mo\Documents\Projects\Chrome Plugin\nixysa-read-only\nixysa\sta
tic_glue\npapi" /I "C:\Users\Mo\Documents\Projects\Chrome Plugin\nixysa-re
ad-only\third_party\npapi\include" /Iglue
globals_glue.cc
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(6361) : error C2146
: syntax error : missing ';' before identifier 'ContextRecord'
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(6361) : error C4430
: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(6361) : error C4430
: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(12983) : error C206
5: 'PCONTEXT' : undeclared identifier
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(12984) : error C214
6: syntax error : missing ')' before identifier 'ContextRecord'
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(12984) : warning C4
229: anachronism used : modifiers on data are ignored
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(12984) : error C218
2: 'RtlCaptureContext' : illegal use of type 'void'
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(12984) : error C249
1: 'RtlCaptureContext' : definition of dllimport data not allowed
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(12984) : error C205
9: syntax error : ')'
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(13372) : error C214
3: syntax error : missing ';' before '__stdcall'
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(13372) : error C443
0: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(13376) : error C443
0: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\winnt.h(14982) : error C386
1: '__readfsdword': identifier not found
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : war
ning C4530: C++ exception handler used, but unwind semantics are not enabled. Sp
ecify /EHsc

我已经搜索了很多,建议的唯一解决方案是当 DXSDK 标头导致冲突时,它们应该在后面的包含目录列表中提及。我确实安装了 DXSDK,但包含目录不在我的 VS9 列表中,也不在 VS 2008 命令提示符的“vcvars32.txt”中。

定义VS命令提示符变量的四行是:

@set PATH=%DevEnvDir%;%VCINSTALLDIR%\BIN;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\Tools\bin;%FrameworkDir%\%Framework35Version%;%FrameworkDir%\%Framework35Version%\Microsoft .NET Framework 3.5 (Pre-Release Version);%FrameworkDir%\%FrameworkVersion%;%VCINSTALLDIR%\VCPackages;%PATH%
@set INCLUDE=%INCLUDE%;%VCINSTALLDIR%\INCLUDE;%VCINSTALLDIR%\ATLMFC\INCLUDE
@set LIB=%VCINSTALLDIR%\ATLMFC\LIB;%VCINSTALLDIR%\LIB;%LIB%
@set LIBPATH=%FrameworkDir%\%Framework35Version%;%FrameworkDir%\%FrameworkVersion%;%VCINSTALLDIR%\ATLMFC\LIB;%VCINSTALLDIR%\LIB;%LIBPATH%

在 VS 命令提示符中,我得到以下 echo %INCLUDE% :

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ATLMFC\INCLUDE;C:\Program
Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE;C:\Program Files\Microsoft SD
Ks\Windows\v7.0\include;

我在命令提示符(使用 nixysa 脚本)和 VS 命令提示符中都运行了 cl.exe 命令,都给出了相同的错误。 我认为生成的 C 代码没有任何问题,因为它是未经编辑的 Hello World,基本上已经过测试,其他似乎没有问题。

所以有什么想法吗?问题可能出在它正在使用的 winnt.h 中还是?

更多信息:Win 7 x64 on Intel Core 2 Duo

【问题讨论】:

    标签: windows visual-studio visual-studio-2008 scons


    【解决方案1】:

    【讨论】:

    • 亲爱的Peter:您提到的链接不再可用。
    • @FaezeAlahabadi 我已经修复了网址,因为它刚刚被网站重组破坏了。 Iirc 所需要的只是将#define X86(由于某种原因我无法显示下划线)添加到您的代码中,或者让您的构建系统将定义传递给编译器。该链接仅用于背景和归属。
    猜你喜欢
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 2021-01-16
    • 1970-01-01
    • 2017-01-03
    • 1970-01-01
    • 2014-01-27
    相关资源
    最近更新 更多