Sign in to follow this  
jrounds

Getting VC to compile with variables declared in the middle of a block

Recommended Posts

jrounds    100
Hi. I am hoping out there in the syrup of preprocessor options for Visual Studio there is one that will get it to compile C code with variables declared in the middle of a block. Back story. GCC (unix) compiles .c files with variables declared in the middle of the block as if they were .cpp files (or some later specification of C perhaps some guru knows). I know original c specification required variables to be declared at the top of blocks, and VC has decided to inforce this. But one of my instructors loves to supply skeleton code/helper functions for c files with variables declared in the middle of a block. I kind of like to go back and forth between gcc on unix (where my code must compile) and VC when I am at home because I am more productive in that environment. I have all issues handled at the moment, but I have to go through supplied code and declare all the variables at the top of blocks to use them while compiling in VC. If such a preprocessor command existed to get VC to operate like GCC in this respect I would love to know it. Thanks for your time.

Share this post


Link to post
Share on other sites
extralongpants    704
Which version of Visual Studio are you using? Microsoft added a little more support for C99 in Visual Studio 2010.

If that doesn't work, I would just try using Eclipse with GCC, or compiling your C files as C++ - I believe there is a setting in visual studio somewhere, possibly in the properties of each .c file. Just make sure you test your programs thoroughly on unix if you go that route.

I really don't think it's worth your time you move variables around.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this