Solved

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

Posted on 2015-01-26
3
249 Views
Last Modified: 2015-01-28
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.
0
Comment
Question by:CarmenMTorres
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 40571612
You need to change the file extension from .C to .cpp (or .cxx). Since Windows isn't case sensitive, the .C files are compiled as plain C, thus causing the load of errors you see...
0
 
LVL 86

Expert Comment

by:jkr
ID: 40571846
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.
0
 
LVL 33

Expert Comment

by:sarabande
ID: 40572797
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
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

830 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