Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 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 35

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This video teaches viewers about errors in exception handling.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

688 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