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
248 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
passing data from one form to another form in c++ 27 80
Message not shown 5 51
Precision Problem in C++ 7 33
Please explain C language error codes ? 5 11
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

832 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