Solved

Windows.h problem

Posted on 2004-09-06
12
24,140 Views
Last Modified: 2013-11-20
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
Comment
Question by:Stephangerlach
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 11989363
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
 

Author Comment

by:Stephangerlach
ID: 11989385
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
 
LVL 13

Expert Comment

by:SteH
ID: 11989487
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
 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

 

Author Comment

by:Stephangerlach
ID: 11989554
I only used the standard settings in the project.

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

0
 
LVL 13

Expert Comment

by:SteH
ID: 11989655
ARe you using precompiled headers (stdafx.h)?
0
 

Author Comment

by:Stephangerlach
ID: 11989699
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
 
LVL 13

Expert Comment

by:SteH
ID: 11989875
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
 

Author Comment

by:Stephangerlach
ID: 11990019
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
 
LVL 13

Expert Comment

by:SteH
ID: 11990113
Instead of reinstalling VC I suppose to recreate a new clean project in its own folder.
0
 

Author Comment

by:Stephangerlach
ID: 11990247
Did that too and the error is still there :@ its annoying me now
0
 
LVL 19

Accepted Solution

by:
drichards earned 100 total points
ID: 11992649
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
 

Author Comment

by:Stephangerlach
ID: 11994593
I dont know why but the basetsd.h was something totally different. its working now. Thanks
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question