Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 24236
  • Last Modified:

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
0
Stephangerlach
Asked:
Stephangerlach
  • 6
  • 5
1 Solution
 
SteHCommented:
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)
0
 
StephangerlachAuthor Commented:
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
0
 
SteHCommented:
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?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
StephangerlachAuthor Commented:
I only used the standard settings in the project.

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

0
 
SteHCommented:
ARe you using precompiled headers (stdafx.h)?
0
 
StephangerlachAuthor Commented:
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.
0
 
SteHCommented:
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.
0
 
StephangerlachAuthor Commented:
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.
0
 
SteHCommented:
Instead of reinstalling VC I suppose to recreate a new clean project in its own folder.
0
 
StephangerlachAuthor Commented:
Did that too and the error is still there :@ its annoying me now
0
 
drichardsCommented:
It looks to me like you've got a bad 'basetsd.h' file.  Line 1092 of winnt.h is using UINT_PTR which should be defined in basetsd.h.  'basetsd.h' is #include'd by winnt.h.  None of the basetsd.h errors make any sense, though, because none of the referenced symbols exist there (if you've got a good version of it).  Here's a copy of my basetsd.h for comparison.  If yours doesn't look like this, copy it off and replace it.  Also, if you do have a bogus bastsd.h, it does make your Visual Studio installation suspect unless you have an idea how it might have happened.
----------------------------------------------------------------------------
/*++

Copyright (c) 1997-1998  Microsoft Corporation

Module Name:

    basetsd.h

Abstract:

    Type definitions for the basic sized types.

Author:

    Jeff Havens (jhavens)   23-Oct-1997

Revision History:

--*/

#ifndef _BASETSD_H_
#define _BASETSD_H_

#ifdef __cplusplus
extern "C" {
#endif

//
// The following types are guaranteed to be signed and 32 bits wide.
//

typedef int LONG32, *PLONG32;
typedef int INT32, *PINT32;

//
// The following types are guaranteed to be unsigned and 32 bits wide.
//

typedef unsigned int ULONG32, *PULONG32;
typedef unsigned int DWORD32, *PDWORD32;
typedef unsigned int UINT32, *PUINT32;

//
// The INT_PTR is guaranteed to be the same size as a pointer.  Its
// size with change with pointer size (32/64).  It should be used
// anywhere that a pointer is cast to an integer type. UINT_PTR is
// the unsigned variation.
//
// HALF_PTR is half the size of a pointer it intended for use with
// within strcuture which contain a pointer and two small fields.
// UHALF_PTR is the unsigned variation.
//

#ifdef _WIN64

typedef __int64 INT_PTR, *PINT_PTR;
typedef unsigned __int64 UINT_PTR, *PUINT_PTR;

#define MAXINT_PTR (0x7fffffffffffffffI64)
#define MININT_PTR (0x8000000000000000I64)
#define MAXUINT_PTR (0xffffffffffffffffUI64)

typedef unsigned int UHALF_PTR, *PUHALF_PTR;
typedef int HALF_PTR, *PHALF_PTR;

#define MAXUHALF_PTR (0xffffffffUL)
#define MAXHALF_PTR (0x7fffffffL)
#define MINHALF_PTR (0x80000000L)

#pragma warning(disable:4311)   // type cast truncation

#if !defined(__midl)
__inline
unsigned long
HandleToUlong(
    void *h
    )
{
    return((unsigned long) h );
}

__inline
unsigned long
PtrToUlong(
    void  *p
    )
{
    return((unsigned long) p );
}

__inline
unsigned short
PtrToUshort(
    void  *p
    )
{
    return((unsigned short) p );
}

__inline
long
PtrToLong(
    void  *p
    )
{
    return((long) p );
}

__inline
short
PtrToShort(
    void  *p
    )
{
    return((short) p );
}
#endif
#pragma warning(3:4311)   // type cast truncation

#else


typedef long INT_PTR, *PINT_PTR;
typedef unsigned long UINT_PTR, *PUINT_PTR;

#define MAXINT_PTR (0x7fffffffL)
#define MININT_PTR (0x80000000L)
#define MAXUINT_PTR (0xffffffffUL)

typedef unsigned short UHALF_PTR, *PUHALF_PTR;
typedef short HALF_PTR, *PHALF_PTR;

#define MAXUHALF_PTR 0xffff
#define MAXHALF_PTR 0x7fff
#define MINHALF_PTR 0x8000

#define HandleToUlong( h ) ((ULONG) (h) )
#define PtrToUlong( p ) ((ULONG) (p) )
#define PtrToLong( p ) ((LONG) (p) )
#define PtrToUshort( p ) ((unsigned short) (p) )
#define PtrToShort( p ) ((short) (p) )

#endif

//
// SIZE_T used for counts or ranges which need to span the range of
// of a pointer.  SSIZE_T is the signed variation.
//

typedef UINT_PTR SIZE_T, *PSIZE_T;
typedef INT_PTR SSIZE_T, *PSSIZE_T;

//
// The following types are guaranteed to be signed and 64 bits wide.
//

typedef __int64 LONG64, *PLONG64;
typedef __int64 INT64, *PINT64;


//
// The following types are guaranteed to be unsigned and 64 bits wide.
//

typedef unsigned __int64 ULONG64, *PULONG64;
typedef unsigned __int64 DWORD64, *PDWORD64;
typedef unsigned __int64 UINT64, *PUINT64;

#ifdef __cplusplus
}
#endif

#endif // _BASETSD_H_
0
 
StephangerlachAuthor Commented:
I dont know why but the basetsd.h was something totally different. its working now. Thanks
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now