• Advertisement
Sign in to follow this  

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

This topic is 3024 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
Sign in to follow this  

  • Advertisement