Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to compile Non Ansi C code in Microsoft Visual Studio v.6 C/C++

Status
Not open for further replies.

jimbo24uk

Programmer
Feb 11, 2007
1
0
0
GB
Hello,

I have inherited a large piece of C code which was written in a non ansi compliant compiler. This compiler allowed variable declaration anywhere within a function body, whereas the Microsoft visual studio version 6 C compiler insists that all variables must be declared at the beginning of a function body. I dont have knowledge or access to the old compiler, so I am trying to get the code compiling in Visual studio C/C++ ver 6. It is a big job to go through the code and move all variables to the beginning of the function they are declared in so I have been trying to see if it is possible to switch off in Visual studio the rule that all variables must be declared at the beginning of a function body.

So far I have tried renaming my files from .C to .CPP and also I tried changing my C/C++ compiler settings switch from /Tc to /TP. This enabled me to compile the code with variables declared anywhere in a function however I now find parts of the code which uses the keywords "enum" and "typedef struct" no longer compiles.

Any suggestions would be greatly appreciated.
Thanks in advance
 
Change

typedef struct {
...
} ABCD;

to

struct ABCD {
...
};

C++ can reference ABCD directly. Same for typedef enum. Alternatively post an example of the code that doesn't compile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top