954,157 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

windows.h error

I am using this code here:

#include "stdafx.h"
#include "windows.h"


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
    LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
    return 0;
}


But no matter what i do i keep getting this built error:


------ Build started: Project: Gui, Configuration: Debug Win32 ------
Compiling...
Gui.cpp
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(236) : error C2146: syntax error : missing ';' before identifier 'PVOID64'
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(236) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C2146: syntax error : missing ';' before identifier 'Buffer'
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int


I was wondering if anyone will be able to help me out so it will be able to compile.

Cheers
Paul

Paul Thompson
Veteran Poster
1,119 posts since May 2008
Reputation Points: 264
Solved Threads: 183
 

I started a new empty windows project, pasted your code and it compiled without any errors or warnings. When you created your project did you create a console project or windows project. It must be a windows project.

Ancient Dragon
Retired & Loving It
Team Colleague
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 

Yeah i am using the "Win32 Project" and even the default one dosent compile. Do i have to reinstall an SDK? Or is there something else?

Paul Thompson
Veteran Poster
1,119 posts since May 2008
Reputation Points: 264
Solved Threads: 183
 

What version of Windows are you running? I have Vista but some people say that VC++ 6.0 doesn't work right on that os. Recommend you upgrade to the latest version of the compiler -- VC++ 2008 Express is free but doesn't support MFC.

Ancient Dragon
Retired & Loving It
Team Colleague
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 

In addition to what Ancient already mentioned:
Change #include "windows.h" to #include <windows.h>

Nick Evan
Not a Llama
Moderator
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
 
In addition to what Ancient already mentioned: Change #include "windows.h" to #include <windows.h>


It really doesn't matter with that compiler.

Ancient Dragon
Retired & Loving It
Team Colleague
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 

Yeah it runs on my second computer fine.. The only problem seems to be with winnt.h.. Should i just redownload that file from somewhere? And i am using XP, and Visual C++ 6

Paul Thompson
Veteran Poster
1,119 posts since May 2008
Reputation Points: 264
Solved Threads: 183
 

try this. I have vc++ 6.0 sp 6 installed

Ancient Dragon
Retired & Loving It
Team Colleague
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 

With MSVC 6.0, the latest Windows SDK that can be used is the Windows Server 2003 Platform SDK

Either switch to that old SDK or get e.g. a VS Express edition, which works with your current SDK.

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

Thanks Ancient Dragon, that fixed the issues with winnt.h, but winbase.h is stuffed. I think this comes from my brother trying direct x with no success some time ago.

So does anyone know where i can get a replacement winbase.h?

Or perhaps where i could just re-download all headers?

Paul Thompson
Veteran Poster
1,119 posts since May 2008
Reputation Points: 264
Solved Threads: 183
 
So does anyone know where i can get a replacement winbase.h? Or perhaps where i could just re-download all headers?


Don't ever replace/modify the system header files, instead simply get a complete SDK, which is guaranteed to be compatible with your compiler.

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

Okay so i have windows XP, Microsoft Visual C++ 2008 Express Edition, what SDK do i need?

Paul Thompson
Veteran Poster
1,119 posts since May 2008
Reputation Points: 264
Solved Threads: 183
 
Okay so i have windows XP, Microsoft Visual C++ 2008 Express Edition, what SDK do i need?

You might look at Using Visual C++ 2008 Express with the Windows SDK

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

With MSVC 6.0, the latest Windows SDK that can be used is the Windows Server 2003 Platform SDK

Either switch to that old SDK or get e.g. a VS Express edition, which works with your current SDK.

I'm running MSVC 6.0 on Vista Home Premium, but I agree with upgrading to VC++ 2008 (Express or another version)

Ancient Dragon
Retired & Loving It
Team Colleague
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 
Okay so i have windows XP, Microsoft Visual C++ 2008 Express Edition, what SDK do i need?

Depends on what you are trying to do. The compiler contains everything you need to write simple gui programs using win32 api functions. If you want MFC then you can't use the Express edition at all because it doesn't support MFC. If you want something beyond the basic gui functions then you probably should download the entire Windows Platform SDK, which is quite large.

Ancient Dragon
Retired & Loving It
Team Colleague
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 
I'm running MSVC 6.0 on Vista Home Premium

Umm, maybe you misunderstood me (?). I was not trying to say that MSVC 6.0 cannot be used on Windows versions later than "Windows Server 2003".

Instead, I was trying to say that the "Windows Server 2003Platform SDK" is the last SDK version that is compatible and works with MSVC 6.0.

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

Umm, maybe you misunderstood me (?). I was not trying to say that MSVC 6.0 cannot be used on Windows versions later than "Windows Server 2003".

Instead, I was trying to say that the "Windows Server 2003 Platform SDK" is the last SDK version that is compatible and works with MSVC 6.0.

Oops! you are right.

Ancient Dragon
Retired & Loving It
Team Colleague
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 

Cheers, i re-installed all of the headers and its worked!

Thanks guys,
Cheers

Paul Thompson
Veteran Poster
1,119 posts since May 2008
Reputation Points: 264
Solved Threads: 183
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You