Link to home
Start Free TrialLog in
Avatar of Stephangerlach
Stephangerlach

asked on

Windows.h problem

Hi everyone

I got a problem with the windows.h file. i wrote only a simple programe and it gives me loads of errors.

#include <windows.h>
#include <iostream.h>

int main ( void )
{
     cout << "hello";
     return (0);
}



this gives me the following errors

c:\program files\microsoft visual studio\vc98\include\basetsd.h(22) : error C2143: syntax error : missing ';' before '__stdcall'
c:\program files\microsoft visual studio\vc98\include\basetsd.h(22) : error C2501: 'LRESULT' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\basetsd.h(22) : error C2065: 'HWND' : undeclared identifier
c:\program files\microsoft visual studio\vc98\include\basetsd.h(22) : error C2146: syntax error : missing ')' before identifier 'hwnd'
c:\program files\microsoft visual studio\vc98\include\basetsd.h(22) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft visual studio\vc98\include\basetsd.h(22) : error C2501: 'WndProc' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\basetsd.h(22) : error C2059: syntax error : ')'
c:\program files\microsoft visual studio\vc98\include\basetsd.h(26) : error C2065: 'HINSTANCE' : undeclared identifier
c:\program files\microsoft visual studio\vc98\include\basetsd.h(26) : error C2146: syntax error : missing ')' before identifier 'hInstance'
c:\program files\microsoft visual studio\vc98\include\basetsd.h(26) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft visual studio\vc98\include\basetsd.h(26) : error C2059: syntax error : ')'
c:\program files\microsoft visual studio\vc98\include\basetsd.h(27) : error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft visual studio\vc98\include\basetsd.h(27) : error C2447: missing function header (old-style formal list?)
c:\program files\microsoft visual studio\vc98\include\basetsd.h(97) : error C2143: syntax error : missing ';' before '__stdcall'
c:\program files\microsoft visual studio\vc98\include\basetsd.h(97) : error C2501: 'LRESULT' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\basetsd.h(97) : error C2086: 'LRESULT' : redefinition
c:\program files\microsoft visual studio\vc98\include\basetsd.h(97) : error C2146: syntax error : missing ')' before identifier 'hwnd'
c:\program files\microsoft visual studio\vc98\include\basetsd.h(97) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft visual studio\vc98\include\basetsd.h(97) : error C2501: 'WndProc' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\basetsd.h(97) : error C2086: 'WndProc' : redefinition
c:\program files\microsoft visual studio\vc98\include\basetsd.h(97) : error C2059: syntax error : ')'
c:\program files\microsoft visual studio\vc98\include\basetsd.h(98) : error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft visual studio\vc98\include\basetsd.h(98) : error C2447: missing function header (old-style formal list?)
c:\program files\microsoft visual studio\vc98\include\winnt.h(1092) : error C2146: syntax error : missing ';' before identifier 'KSPIN_LOCK'
c:\program files\microsoft visual studio\vc98\include\winnt.h(1092) : fatal error C1004: unexpected end of file found
Error executing cl.exe.


any idea why? i use windows XP and MS VS 6.0
Avatar of Member_2_1001466
Member_2_1001466

I would propose to use

#include <windows.h>
#include <iostream> // no .h here. Other version is deprecated.

int main ( void )
{
     std::cout << "hello";
     return (0);
}

But this doesn't solve the problem. From the last error message I assume that you have parts before those includes. And these seem to have some open parenthesis (inlcuding #ifdef without #endif)
Avatar of Stephangerlach

ASKER

No there are no other parts before the first include. The code I posted is all i have. I had a problem in some other programe and we narrowed the problem down to the windows.h file. I used this code just as an example. But this code is all I have. And it still thows those errors at me
I tested it here using XP SP1 and VC++ 6.0 SP5 (or 6) and it compiles and executes as expected. So there could be some project options being the culprit. What defines are done in the project?
I only used the standard settings in the project.

defines in the project: WIN32,_DEBUG,_CONSOLE,_MBCS

ARe you using precompiled headers (stdafx.h)?
i just changed the code to

#include <windows.h>

int main (void)
{
    return(0);
}

and it gives me the 22 errors. Im not very good with c++ so i dont think im using precompiled headers.
Standard of VS C++ is using precompiled headers. The file view should list stdafx.h and stdafx.cpp in that case. To switch it off go at Project->Settings In the dialog select C++ tab and precompiled header category. Now you can change it to not use precompiled headers for the moment. Next  rebuild all to assure that modified project settings are in effect.

The code you are posting here is not the origin of your problems. That compiles without any problems on my PC.
sorry to tell you but its still not working.
Any other idea? If not I think i will have to end up with reinstalling VC again.
Instead of reinstalling VC I suppose to recreate a new clean project in its own folder.
Did that too and the error is still there :@ its annoying me now
ASKER CERTIFIED SOLUTION
Avatar of drichards
drichards

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I dont know why but the basetsd.h was something totally different. its working now. Thanks