Solved

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

Posted on 2000-04-28
15
695 Views
Last Modified: 2013-12-04
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
Comment
Question by:Ewa
  • 6
  • 4
  • 3
  • +2
15 Comments
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2760694
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
 
LVL 3

Expert Comment

by:SamHobbs
ID: 2762308
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
 
LVL 1

Expert Comment

by:mattdaimon
ID: 2764396
I think not all files you need are included, this may be cause of some
constructions like
#if !defined. Maybe some MFCVER checking.
0
 

Author Comment

by:Ewa
ID: 2768674
Adjusted points from 200 to 400
0
 

Author Comment

by:Ewa
ID: 2768675

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
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2768846
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
 

Author Comment

by:Ewa
ID: 2769367
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:pjknibbs
ID: 2769719
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
 
LVL 3

Expert Comment

by:SamHobbs
ID: 2769868
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
 

Author Comment

by:Ewa
ID: 2770094
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
 
LVL 2

Expert Comment

by:abesoft
ID: 2770148
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
 
LVL 3

Expert Comment

by:SamHobbs
ID: 2770545
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
 
LVL 3

Accepted Solution

by:
SamHobbs earned 400 total points
ID: 2770555
I suppose you could try just defining WIN32_LEAN_AND_MEAN at the beginning of cthermom.cpp.
0
 

Author Comment

by:Ewa
ID: 2772822
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
 

Author Comment

by:Ewa
ID: 2772828
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now