views:

1968

answers:

9

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

#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.

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.

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

A: 

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.)

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.

I have never built this project with a prior version , it's a new project , I tried cleaning it and then recreating it without precompiled headers but still the same problems occur
A: 

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

t.g.
I have a read that solution somewhere , it regarded people using an old standard way using "int main()" instead of "int _tmain" and such , not only that I used "_tmain" but I also tried changing that setting which didn't solve the problem
if you are running on XP, there's a bug of installing beta 1 on XP. please check whether or not you have this property sheet: "Microsoft.Cpp.Win32.User". If not, try this link: http://blogs.msdn.com/vsproject/archive/2009/07/07/vc-directories.aspx
t.g.
+1  A: 

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.

See this question for more details:

Michael Burr
A: 

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

   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?

A: 

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

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.

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"

  • just delete "C:\WinDDK\6001.18001\inc\api\sal.h" :)
miniak
A: 

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:

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

The two files are:

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

Edit the IncludePath variable

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

JasonE
A: 

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.

A: 

Thanks, miniak !!

Your Answer is my solution when just now.

I have this problem too.

LeeJinwoo
@LeeJinwoo: just a friendly reminder - this kind of remark is usually made as a comment under the answer that you are referring to.
Samuel Jack
A: 

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.

Justin