compile erros with Microsoft SDK files
-
Friday, April 13, 2012 10:35 PM
I'm doing a build and one of the early messages is:
WINVER not defined. Defaulting to 0x0600 (Windows Vista)
and then I get compile errors with this file:
c:\program files\microsoft sdks\windows\v6.0a\include\netioapi.h
The three errors are:
error C2146: syntax error : missing ';' before identifier... error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Now from the last two I can tell it is something with the version of compiler I am using. I am using VS2008. In the path to these files I see "v6.0a" and so I wonder if this SDK is for Visual C++ 6.0?
Is this true? I must install a new version of the SDK, compatible with VS2008?
All Replies
-
Saturday, April 14, 2012 12:49 AM>from the last two I can tell it is something with the
>version of compiler I am using.
Not exactly. No recent version of any C++ compiler will
default to type int when a type ison't specified.
Implicit int is not supported by ANSI/ISO Standard C++.
The first error shown will result in the second two.
That first error is probably caused by a missing or
incomplete header file in your program. You should
have
#include <windows.h>
as the first include in your code.
>In the path to these files I see "v6.0a" and so I
>wonder if this SDK is for Visual C++ 6.0?
No. The version of the Win SDK has no relationship
to the version of the C++ compiler. That is the
correct version for VC++ 2008 and is the version
of the SDK which will be installed with VC++ 2008,
- Wayne- Proposed As Answer by Helen ZhaoModerator Monday, April 16, 2012 6:34 AM
- Unproposed As Answer by msnhelpsme Monday, April 16, 2012 3:51 PM
-
Saturday, April 14, 2012 2:23 AM>You should have
>#include <windows.h>
>as the first include in your code.
Clarification: If using precompiled headers (PCH),
this include should come *after* stdafx.h which
needs to be first for PCH.
- Wayne -
Saturday, April 14, 2012 8:02 AM
>You should have
>#include <windows.h>
>as the first include in your code.
Clarification: If using precompiled headers (PCH),
this include should come *after* stdafx.h which
needs to be first for PCH.
- Wayne
Or, even inside stdafx.h
-- pa
-
Monday, April 16, 2012 3:08 PM
Ok, I put #include <windows.h> in stdafx.h (windows.h had been included in various other files, some .h and some .c/.cpp but not all of them) and now I see this:
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
Now I think this is a custom error message, if my knowledge of "#error" is correct. I'm not sure what an MFC app has to do with this, but stdafx.h looks like this:
#if !defined(AFX_STDAFX_H__......) #define AFX_STDAFX_H__...... #if _MSC_VER > 1000 #pragma once #endif #define VC_EXTRALEAN #include <windows.h> #include <afxwin.h> #include <afxext.h> #include <afxdtctl.h> #ifndef _AFX_NO_AFXCMN_SUPPORT #include <afxcmn.h> #endif #include "BaseTsd.h" #endif
So apparently this project uses MFC. How does that relate to my initial error? -
Monday, April 16, 2012 5:25 PM
check this link this may help you out
http://msdn.microsoft.com/en-us/library/aa383745%28v=vs.85%29.aspx
-
Monday, April 16, 2012 6:06 PMIm not sure what I should be looking for though. I mean, I can define WINVER, but to what?
-
Monday, April 16, 2012 6:31 PMAlso see:
Modifying WINVER and _WIN32_WINNT
http://msdn.microsoft.com/en-us/library/6sehtctf.aspx
- Wayne -
Monday, April 16, 2012 8:55 PM
Also see:
Modifying WINVER and _WIN32_WINNT
http://msdn.microsoft.com/en-us/library/6sehtctf.aspx
- Wayne
Ok I added
/D WINVER=0x0601
to the command line for compiling, but I still get the same 3 errors as mentioned in the original post. -
Monday, April 16, 2012 9:31 PM
Ok I added
There shouldn't be a space in there:/D WINVER=0x0601
/DWINVER=0x0601
- Wayne -
Monday, April 16, 2012 10:25 PM
Ok, I put #include <windows.h> in stdafx.h (windows.h had been included in various other files, some .h and some .c/.cpp but not all of them) and now I see this:
afxwin.h is MFC's replacement for windows.h (it includes windows.h itself), so remove the windows.h include above.
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
Now I think this is a custom error message, if my knowledge of "#error" is correct. I'm not sure what an MFC app has to do with this, but stdafx.h looks like this:
#if !defined(AFX_STDAFX_H__......)
#define AFX_STDAFX_H__......
#if _MSC_VER > 1000
#pragma once
#endif
#define VC_EXTRALEAN
#include <windows.h>
#include <afxwin.h>
David Wilkinson | Visual C++ MVP -
Tuesday, April 17, 2012 4:20 AM
but I still get the same 3 errors as mentioned in the original post.
>and then I get compile errors with this file:
>c:\program files\microsoft sdks\windows\v6.0a\include\netioapi.h
>The three errors are:
>error C2146: syntax error : missing ';' before identifier...
Nobody can tell you the exact cause of those errors
without seeing the code preceding them. The usual
cause in cases such as this is an error in a header
file (or immediate code) before the header in
question is included. It's often caused by a
missing semicolon after the closing brace in a
structure or class definition. The parser keeps
reading lines of code after that closing brace
and treating them as part of the struct/class,
until it encounters something which simply won't
fit anymore. The actual cause is therefore somewhere
before the line indicated in the first error message.
You need to set the Project Property to "Show Includes".
Then examine the Output window from a build to see what
is preceding netioapi.h - and perhaps also use
"Generate Preprocessed File" to see the complete
code from the headers. Then work back from the
first error line to locate the source of the
problem.
- Wayne
-
Tuesday, April 17, 2012 10:52 AM
I am using VS2008. In the path to these files I see "v6.0a" and so I wonder if this SDK is for Visual C++ 6.0?
This question is already answered in this thread. The "v6.0a" has nothing to do with VC6, and it is the version that comes with VS2008.
Is this true? I must install a new version of the SDK, compatible with VS2008?
David Wilkinson | Visual C++ MVP -
Wednesday, April 18, 2012 3:34 PM
Ok, I turned on "Show Includes". There are a lot of MFC and SDK files being included before the SDK file that has the problem. The ONLY file from my project that is included before this is stdafx.h. I already posted my stdafx.h above. No one seemed to see a problem with it. Maybe the MFC headers I am including are old? I know nothing about MFC so if someone could comment on those, that'd be great.Nobody can tell you the exact cause of those errors
without seeing the code preceding them. The usual
cause in cases such as this is an error in a header
file (or immediate code) before the header in
question is included.
You need to set the Project Property to "Show Includes".
Then examine the Output window from a build to see what
is preceding netioapi.h
-
Wednesday, April 18, 2012 10:52 PM
If it helps any, the issue could be because I upgraded to VS2008. This project compiled previously in VC6.0. I know some things that used to be warnings in the old compiler are now errors in VS2008.- Proposed As Answer by Helen ZhaoModerator Monday, April 23, 2012 2:12 AM

