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
246 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 32

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

758 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

21 Experts available now in Live!

Get 1:1 Help Now