Link to home
Start Free TrialLog in
Avatar of Maria Torres
Maria Torres

asked on

Why VS 2010 Express produces C2061 error on an old program that compiled successfully at one time with an old compiler?

I am not a C++ programmer, but I was assigned to compile an old program that was once compiled for a Unix  machine.  The program now needs to run in Windows.

When I try to compile the program in Visual Studio 2010 Express, I receive over 100 error messages.  The errors that mainly shows up is the C2061: syntax error: Identifier ....

I've provided a snippet of the code to illustrate the error:

The code start of as follows:



#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>



// class and structure declarations

class PATIENT;         // a patient record
class RULE;            // a rule from the file of pretty rules
class LINK;            // a node in a rule tree
struct TRIPLE;         // a staging triple (dx category, stage, pflag)
class DXLINK;          // single dx link
class DXRLINK;         // dx range link
class STLINK;          // stage link
class XLINK;           // sex link
class WLINK;           // without clause link
struct STAGE;          // dxcat and stage
struct DXRANGE;        // lo and hi dxs


.....



The error message generates  for the above code lines are as follows:


1>------ Build started: Project: Stager, Configuration: Debug Win32 ------
1>  stager.C
1>s:\carmen\stager.c(15): error C2061: syntax error : identifier 'PATIENT'
1>s:\carmen\stager.c(15): error C2059: syntax error : ';'
1>s:\carmen\stager.c(16): error C2061: syntax error : identifier 'RULE'
1>s:\carmen\stager.c(16): error C2059: syntax error : ';'
1>s:\carmen\stager.c(17): error C2061: syntax error : identifier 'LINK'
1>s:\carmen\stager.c(17): error C2059: syntax error : ';'
1>s:\carmen\stager.c(19): error C2061: syntax error : identifier 'DXLINK'
1>s:\carmen\stager.c(19): error C2059: syntax error : ';'
1>s:\carmen\stager.c(20): error C2061: syntax error : identifier 'DXRLINK'
1>s:\carmen\stager.c(20): error C2059: syntax error : ';'
1>s:\carmen\stager.c(21): error C2061: syntax error : identifier 'STLINK'
1>s:\carmen\stager.c(21): error C2059: syntax error : ';'

...

=============


If anyone can help me with this error, I really would appreciate it so that I can move forward with the program.

Thank you for your assistance.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

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
BTW, just in case I was unclear about that (and I might well have been): When Visual Studio decides to invoke the C compiler and not the C++ compiler - based on the file extension - all C++ features such as classes will be unavailable, which in return causes all these errors.
to add to above comment:

you could change the compiler associated to a source file regardless of its file extension.

you would do that by setting the /TP compiler option.

see https://msdn.microsoft.com/en-us/library/032xwy55.aspx for details.

the option can be found at Properties - Configuration Properties - C/C++ - Advanced - Compile As and can be set for a single file or for the project for debug and release or all configurations.

Sara