user112771
user112771

Reputation: 359

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:

#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

Upvotes: 20

Views: 27755

Answers (12)

GlamSelva1297934
GlamSelva1297934

Reputation: 137

  1. To Avoid MFC, WTL and ATL Error.

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

  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

Upvotes: 0

Zoran
Zoran

Reputation: 101

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

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.

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!

Upvotes: 3

zhangjiadan
zhangjiadan

Reputation: 11

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

Upvotes: 1

Juriy Petrochenkov
Juriy Petrochenkov

Reputation: 51

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

Upvotes: 5

Justin
Justin

Reputation: 11

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.

Upvotes: 1

user350091
user350091

Reputation: 11

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.

Upvotes: 1

JasonE
JasonE

Reputation: 896

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.

Upvotes: 1

user278858
user278858

Reputation:

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" :)

Upvotes: 24

user112771
user112771

Reputation: 359

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?

Upvotes: 0

Michael Burr
Michael Burr

Reputation: 340218

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:

Upvotes: 4

t.g.
t.g.

Reputation: 1749

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

Upvotes: 0

Peter Cardona
Peter Cardona

Reputation: 2110

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.

Upvotes: 0

Related Questions