基於VS2010 Beta 1的c++應用程序的多個編譯錯誤。

[英]multiple compiling errors with basic C++ application on VS2010 Beta 1


I just recently installed VS2010 Beta 1 from the Microsoft website , I started a basic C++ Win32 Console Application , that generated the following code:

我剛剛在微軟網站上安裝了VS2010 Beta 1,我啟動了一個基本的c++ Win32控制台應用程序,生成了以下代碼:

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{

return 0;
}

I tried compiling the code just to see how it runs and just then I encountered several(over a 100) compiling errors.

我嘗試編譯代碼只是為了看看它是如何運行的,然后我遇到了幾個(超過100個)編譯錯誤。

Here is the first part of the build output:

這里是構建輸出的第一部分:

1>ClCompile:
1>  stdafx.cpp
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): error C2065: '_In_opt_z_' : undeclared identifier
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): warning C4229: anachronism used : modifiers on data are ignored
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): error C2182: '_invalid_parameter' : illegal use of type 'void'
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): error C2491: '_invalid_parameter' : definition of dllimport data not allowed
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(527): error C2065: '_In_opt_z_' : undeclared identifier
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(527): error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(527): warning C4229: anachronism used : modifiers on data are ignored

pastebin for the full list

巴斯德的完整列表。

I thought maybe the include files got mixed up by some other compiler version I have installed previously( I have VS 2008 as well) so I reinstalled VS2010 just to overwrite the headers but that didn't do much.

我想,可能包括我之前安裝的其他編譯器版本的include文件(我也有VS 2008),所以我重新安裝了VS2010,只是為了覆蓋標題,但這並沒有起到什么作用。

Thanks in advance for any help you might offer as I am helpless

感謝你在我無助的時候提供的幫助。

12 个解决方案

#1


24  

The problem is here: C:\WinDDK\6001.18001\inc\api\sal.h

這里的問題是:C:\WinDDK\6001.18001\。

sal.h defines annotations, which are being used in the CRT headers... The DDK includes its own sal.h, which is obsolete and dones not contain all the annotations.

薩爾。h定義了注釋,它在CRT標題中被使用…DDK包括它自己的sal。h,已經過時了,dones不包含所有的注釋。

There are 2 possible solutions: - change the include paths so that the "C:\Program Files\Microsoft Visual Studio 10.0\VC\include" comes before "C:\WinDDK\6001.18001\inc\api"

有兩種可能的解決方案:-更改include路徑,以使“C:\程序文件\ microsoftvisual Studio 10.0\VC\包括”在“C:\WinDDK\6001.18001\inc\api”之前。

  • just delete "C:\WinDDK\6001.18001\inc\api\sal.h" :)
  • 刪除“C:\ WinDDK \ 6001.18001 \企業\ api \薩爾。h:)

#2


6  

Just use '$(IncludePath);C:\WinDDK\6001.18001\inc\api' as include directories.

只需要使用“$(IncludePath);C:\WinDDK\6001.18001\ api”,包括目錄。

#3


4  

Something is wrong with your include path. Use the the "/showIncludes" option ("Configuration Properties/C/C++/Advanced/Show Includes" in the IDE's project options) to see what headers are being included from where.

你的include路徑有問題。使用“/ showinclude”選項(“配置屬性/C/ c++ /高級/顯示包括”在IDE的項目選項中),以查看包含在哪里的頭信息。

See this question for more details:

詳情請見此問題:

#4


3  

I had the same problem after adding the path to the DDK directory in the project property pages under

在添加到項目屬性頁下面的DDK目錄的路徑之后,我遇到了同樣的問題。

Configuration Properties -> C/C++ -> Additional Include Directories

After changing the location to

將位置更改為。

Configuration Properties -> VC++ Directories -> Include Directories

and adding the path to the DDK after $(IncludePath) everything worked fine.

並且在$(IncludePath)之后添加到DDK的路徑,一切都很好。

Juriy Petrochenkov was on the right track with his remark, so I rechecked where I have added the DDK directory to, and, lo and behold, it was the wrong one. Thank's Juriy!

他的評論是正確的,所以我重新檢查了我在哪里添加了DDK目錄,並且,你看,這是錯誤的。謝謝Juriy !

#5


1  

I have found that my include directory was inheritting from parent or project defaults. The problem is that in VS2010 the Global options for include paths has been removed. After some searching, I found that the two files that contained these settings (From my previous install of VS) were in the following directory:

我發現,我的include目錄是從父類或項目默認值中繼承的。問題是,在VS2010中,包含路徑的全局選項已經被刪除。在進行了一些搜索之后,我發現包含這些設置的兩個文件(從我之前安裝的VS)在以下目錄中:

C:\users\username\appdata\local\microsoft\msbuild\v4.0\

當地用戶C:\ \用戶名\ appdata \ \ \ msbuild \ v4.0 \微軟

The two files are:

這兩個文件是:

  1. Microsoft.Cpp.Win32.user.props
  2. Microsoft.Cpp.Win32.user.props
  3. Microsoft.Cpp.x64.users.props
  4. Microsoft.Cpp.x64.users.props

Edit the IncludePath variable

編輯IncludePath變量

Remove the DDK path, saved the file, and restarted VS2010. This resolved my issue for all new projects.

刪除DDK路徑,保存文件,並重新啟動VS2010。這解決了我所有新項目的問題。

#6


1  

Yes, changing the users.prop works, but how strange! You can't change this setting from a menu in Visual Studio and you can't overwrite it in the project properties. Even if you erase the setting just putting in $(IncludePath) it nevertheless uses the default path to the DDK.

是的,改變了用戶。道具很好用,但是太奇怪了!您不能從Visual Studio的菜單中更改這個設置,也不能在項目屬性中覆蓋它。即使您刪除了僅僅放入$(IncludePath)的設置,它仍然使用默認的DDK路徑。

#7


1  

or you can add, $(VSInstallDir)\VC\include\sal.h to the forced includes setting in your C++ advanced settings. This will force crtdef.h line #include <sal.h> effectively to #include "sal.h" but much less destructive. forcing it to use the current folder rather than the include system paths.

或者你也可以加上,$(VSInstallDir)\VC\包括\sal。h的強制包括設置在你的c++高級設置。這將迫使crtdef。h線# include <薩爾。h> 有效地包括了“sal”。但是破壞性要小得多。強制它使用當前文件夾而不是包含系統路徑。

#8


1  

I have the same problem, you can copy sal.h from Microsoft Visual Studio 10.0\VC\include to WinDDK\7600.16385.1\inc\api\ and copy Microsoft Visual Studio 10.0\VC\include\CodeAnalysis to WinDDK\7600.16385.1\inc\api\.

我有同樣的問題,你可以復制sal。微軟Visual Studio 10.0\VC\包括WinDDK\7600.16385.1\inc\api\和復制Microsoft Visual Studio 10.0\VC\包括\CodeAnalysis到WinDDK\7600.16385.1\inc\api\。

#9


0  

Did you ever build the project with the prior version? stdafx.h is the standard precompiled header name for msvc projects. If you built with VS2008, it could have created the precompiled header and perhaps VS2010 is picking it up. (If you're not familiar, a precompiled header is build output generated by the compiler that's kept around to speed up compilation of header files the next time you build.)

您是否曾經用先前的版本構建項目?stdafx。h是msvc項目的標准預編譯頭名稱。如果您使用VS2008構建,它可能創建了預編譯頭,可能VS2010正在將其捕獲。(如果您不熟悉的話,預編譯的頭是編譯器生成的輸出,在下一次編譯時,編譯器會不斷地加快編譯頭文件的編譯。)

I'd try a clean, then a manual inspection of the project directory (and build output directory if its in a non-obvious place), then a full build. If that didn't fix it, I'd turn off precompiled headers (at least temporarily) in the project settings and rebuild.

我嘗試一個干凈的,然后手工檢查項目目錄(如果它在一個不明顯的地方,構建輸出目錄),然后一個完整的構建。如果沒有修復,我將在項目設置和重建中關閉預編譯頭(至少是臨時的)。

#10


0  

Try change project-> properties -> configuration properties -> general -> Character Set to "Use Multi-Byte Character Set"

嘗試更改項目->屬性->配置屬性->通用->字符集“使用多字節字符集”

#11


0  

After adding the /showincludes parameter I got the following result:

在添加/showinclude參數之后,我得到了以下結果:

   1>  Note: including file: c:\testapp\stdafx.h
   1>  Note: including file:  c:\testapp\targetver.h
   1>  Note: including file:   C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\WinSDKVer.h
   1>  Note: including file:   C:\WinDDK\6001.18001\inc\api\SDKDDKVer.h
   1>  Note: including file:  C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stdio.h
   1>  Note: including file:   C:\Program Files\Microsoft Visual Studio 10.0\VC\include\crtdefs.h
   1>  Note: including file:    C:\WinDDK\6001.18001\inc\api\sal.h
   1>  Note: including file:    C:\Program Files\Microsoft Visual Studio 10.0\VC\include\vadefs.h

That would make sense that for some reason it loads the two files from the DDK path and not the VS2010 include dir , if that is in fact the problem how do I tell it to use the correct path?

這樣就可以理解為什么它從DDK路徑加載了兩個文件而不是VS2010包括dir,如果這實際上是問題我如何告訴它使用正確的路徑呢?

#12


0  

  1. To Avoid MFC, WTL and ATL Error.
  2. 為了避免MFC, WTL和ATL錯誤。

Goto C/C++General“Additional include Directory” $(SystemDrive)\Program Files\Microsoft Visual Studio 9.0\VC\include

轉到C / c++一般“附加包括目錄”(SystemDrive)美元\程序文件\ \ VC \包括Microsoft Visual Studio 9.0

  1. For windows default macro error. If any windows related macro problem like the following IN, _IN_OPT_ and OUT Goto C/C++Preprocessor“Ignore standard Include path” to YES
  2. 對於windows默認的宏錯誤。如果任何windows相關宏觀問題如下,_IN_OPT_,轉到C / c++預處理“忽略標准包括路徑”是的

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2009/08/31/72f47e93d79ba904e55d2c5dd8f0c400.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com