[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

VC++ 6.0 does not compile old VC++5.0 project

We have an old programme compiled and linked OK using VC++ 5.0 and would like to compile it using VC++ 6.0. No MFC used, old xvtdsp32 used in that project.  When we try to do it we get error: winnt.h(161) : error C2143: syntax error : missing ';' before '*'. Which it is not ( i.e. no ';' is missing). Where and how do we look for the real problem?
0
Ewa
Asked:
Ewa
  • 6
  • 4
  • 3
  • +2
1 Solution
 
pjknibbsCommented:
Well, for a start you work out in which C file the compiler is falling over--this should be listed before the line mentioning WINNT.H. Then you check that C file to see if there are any #includes or #defines before the #include <winnt.h> which might be causing the problem. (BTW, WINNT.H may well be included indirectly--in the C headers I have, it's included by WINDEF.H, which is in turn included by WINDOWS.H).
0
 
SamHobbsCommented:
Can you post the code in the area it is complaining about? That is, the line that it is saying there is a missing semicolon plus a couple of prior lines.
0
 
mattdaimonCommented:
I think not all files you need are included, this may be cause of some
constructions like
#if !defined. Maybe some MFCVER checking.
0
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
EwaAuthor Commented:
Adjusted points from 200 to 400
0
 
EwaAuthor Commented:

here are the errors and below it the code it's complaining about (the line is : typedef CHAR *PCHAR; just under line with VVVVVVVVVVVVVVVVV)

the errors:
compiling...
Cthermom.cpp
c:\program files\microsoft visual studio\vc98\include\winnt.h(161) : error C2143: syntax error : missing ';' before '*'
c:\program files\microsoft visual studio\vc98\include\winnt.h(161) : error C2501: 'PCHAR' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\winnt.h(203) : error C2143: syntax error : missing ';' before '*'
c:\program files\microsoft visual studio\vc98\include\winnt.h(203) : error C2501: 'PSHORT' : missing storage-class or type specifiers.....

the code in winnt.h:
/*++ BUILD Version: 0095     Increment this if a change has global effects

Copyright (c) 1990-1998  Microsoft Corporation

Module Name:

    winnt.h

Abstract:

    This module defines the 32-Bit Windows types and constants that are
    defined by NT, but exposed through the Win32 API.

Revision History:

--*/

#ifndef _WINNT_
#define _WINNT_

#ifdef __cplusplus
extern "C" {
#endif

#include <ctype.h>  
#define ANYSIZE_ARRAY 1      

#if defined(_M_MRX000) && !(defined(MIDL_PASS) || defined(RC_INVOKED)) && defined(ENABLE_RESTRICTED)
#define RESTRICTED_POINTER __restrict
#else
#define RESTRICTED_POINTER
#endif

#if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || (defined(_M_IA64) && !defined(__ICL))
#define UNALIGNED __unaligned
#else
#define UNALIGNED
#endif

#if defined(_M_IA64) && defined(_GENIA64_)
#define __ptr64
#endif

#if defined(_WIN64) || defined(_M_ALPHA)
#define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
#else
#define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
#endif

//
// TYPE_ALIGNMENT will return the alignment requirements of a given type for
// the current platform.
//

#ifndef __cplusplus

#pragma warning(disable:4116)
#define TYPE_ALIGNMENT( t ) \
    FIELD_OFFSET( struct { char x; t test; }, test )

#endif

//
// C_ASSERT() can be used to perform many compile-time assertions:
//            type sizes, field offsets, etc.
//
// An assertion failure results in error C2118: negative subscript.
//

#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]

#if !defined(_MAC) && (defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_IA64)) && (_MSC_VER >= 1100) && !(defined(MIDL_PASS) || defined(RC_INVOKED))
#define POINTER_64 __ptr64
typedef unsigned __int64 POINTER_64_INT;
#if defined(_AXP64_)
#define POINTER_32 __ptr32
#else
#define POINTER_32
#endif
#else
#if defined(_MAC) && defined(_MAC_INT_64)
#define POINTER_64 __ptr64
typedef unsigned __int64 POINTER_64_INT;
#else
#define POINTER_64
typedef unsigned long POINTER_64_INT;
#endif
#define POINTER_32
#endif

#include <basetsd.h>


#if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64)) && !defined(MIDL_PASS)
#define DECLSPEC_IMPORT __declspec(dllimport)
#else
#define DECLSPEC_IMPORT
#endif

#if (_MSC_VER >= 1200)
#define DECLSPEC_NORETURN __declspec(noreturn)
#else
#define DECLSPEC_NORETURN
#endif

typedef void *PVOID;
typedef void * POINTER_64 PVOID64;


#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
#define NTAPI __stdcall
#else
#define _cdecl
#define NTAPI
#endif

//
// Define API decoration for direct importing system DLL references.
//

#if !defined(_NTSYSTEM_)
#define NTSYSAPI DECLSPEC_IMPORT
#else
#define NTSYSAPI
#endif


//
// Basics
//

#ifndef VOID
#define VOID void
typedef char CHAR;
typedef short SHORT;
typedef long LONG;
#endif

//
// UNICODE (Wide Character) types
//

#ifndef _MAC
typedef wchar_t WCHAR;    // wc,   16-bit UNICODE character
#else
// some Macintosh compilers don't define wchar_t in a convenient location, or define it as a char
typedef unsigned short WCHAR;    // wc,   16-bit UNICODE character
#endif

typedef WCHAR *PWCHAR;
typedef WCHAR *LPWCH, *PWCH;
typedef CONST WCHAR *LPCWCH, *PCWCH;
typedef WCHAR *NWPSTR;
typedef WCHAR *LPWSTR, *PWSTR;

typedef CONST WCHAR *LPCWSTR, *PCWSTR;

//
// ANSI (Multi-byte Character) types
//||||||||||||||||||
//VVVVVVVVVVVVVVVVV
typedef CHAR *PCHAR;
typedef CHAR *LPCH, *PCH;

typedef CONST CHAR *LPCCH, *PCCH;
typedef CHAR *NPSTR;
typedef CHAR *LPSTR, *PSTR;
typedef CONST CHAR *LPCSTR, *PCSTR;
0
 
pjknibbsCommented:
It looks to me like VOID is somehow defined before WINNT.H is loaded, so it never performs the

typedef char CHAR;

line. Then, when it reaches the offending line further down, CHAR is not defined, so the preprocessor converts the line to

typedef *PCHAR;

which is obviously an error.

You need to find in which header file *before* WINNT.H is included VOID is spuriously defined.
0
 
EwaAuthor Commented:
undefining VOID certainly removes the original errors, but now I have a whole collection of new ones, in the same winnt.h, further down, i.e. at the code line below VVVVVVVVVVVVVVVVV;

#pragma warning(disable:4035)               // re-enable below

__inline ULONGLONG
NTAPI
Int64ShllMod32 (
    ULONGLONG Value,
    DWORD ShiftCount
    )
{
    __asm    {
        mov     ecx, ShiftCount
        mov     eax, dword ptr [Value]
        mov     edx, dword ptr [Value+4]
        shld    edx, eax, cl
        shl     eax, cl
    }
}

__inline LONGLONG
NTAPI
Int64ShraMod32 (
    LONGLONG Value,
    DWORD ShiftCount
    )
{
    __asm {
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
        mov     ecx, ShiftCount
        mov     eax, dword ptr [Value]
        mov     edx, dword ptr [Value+4]
        shrd    eax, edx, cl
        sar     edx, cl
    }
}

...............

errors are:

:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winnt.h(532) : error C2065: 'mov' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winnt.h(532) : error C2146: syntax error : missing ';' before identifier 'ecx'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winnt.h(532) : error C2065: 'ecx' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winnt.h(533) : error C2146: syntax error : missing ';' before identifier 'mov'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winnt.h(533) : error C2146: syntax error : missing ';' before identifier 'eax'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winnt.h(533) : error C2065: 'eax' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winnt.h(533) : error C2065: 'dword' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winnt.h(533) : error C2146: syntax error : missing ';' before identifier 'ptr'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winnt.h(533) : error C2065: 'ptr' : undeclared identifier...............


etc., etc.
This leaves me even more lost: something rather basic is missing?
0
 
pjknibbsCommented:
I didn't actually mean you should physically *undefine* VOID, I was saying you should find out where it's being spuriously defined. It would help a lot if you posted what's at the top of the C file which is causing the problem--you know, all the includes and what have you.
0
 
SamHobbsCommented:
I am sorry, I did not see the part of your description where you say that the errors were from winnt.h. So yes, we need to see the part of Cthermom.cpp that precedes the #include <winnt.h>.
0
 
EwaAuthor Commented:
pjknibbs: yes, I understand that: there are several suspect files I would have to examine - this was just an experiment to see what happens ( equivalent to finding and removing the spurious defines).

SamHobbs: I'll include the cthermom.cpp code below, the trouble is that there is no direct #include winnt.h, I'll will have to find indirect ones which can be via dde.h, windows.h or windlap.h
- this will have tyo wait for tomorrow.
For what it's worth, here goes for now:

**************************************************************/

//      INCLUDES
#include      "appdef.h"

#include      cThermometer_i
#include      CWindow_i

now, in appdef.h  are just name defs, CThermometer_i is cthermom.h which includes cview.h, which includes ctype.h, which includes... so far I haven't got anywhere near  winnt.h.
It'll have to wait till tomorrow.. Thanks for your help so far!
0
 
abesoftCommented:
If what you want to do is find out who is first defining NULL, then the simplest approach is to define it right at the top of your file:
#define NULL "An unlikely choice"
Then compile your routine.  You should get a redefinition error when somebody else defines it.
0
 
SamHobbsCommented:
winnt.h is included by WINDEF.H which is included by DDE.H and WINDOWS.H. DDE.H is also included by WINDOWS.H (if WIN32_LEAN_AND_MEAN is not defined), so it is probably possible to remove DDE.H. Since the program supposedly compiled using VC 5, I would not expect removal of DDE.H to make a difference, but it might be worth trying.
0
 
SamHobbsCommented:
I suppose you could try just defining WIN32_LEAN_AND_MEAN at the beginning of cthermom.cpp.
0
 
EwaAuthor Commented:
Thanks, everyone: I am going to dissapoint you and give up - we can after all use VC++ 5.0. As it is an old version of our programme, it will only be around for the next few months. I tried to follow your various suggestions and still am far from the solution... No more time, cut my losses.  I'll give the points to SamHobbs as he was the most active correspondent here..

Thanks again.

0
 
EwaAuthor Commented:
Thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 6
  • 4
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now