Using Microsoft Visual Studio to code in C

First step prior to building of Ingres, I need to grab Microsoft Visual Studio. I have been told that Microsoft Visual Studio is a neat tool to build C++, however, I have never heard anything about it for C code. Therefore, the first thing I explore about Visual Studio is that how to get it to work with C code.

Step #0: Know more about Microsoft Visual Studio

Step #1: Get Microsoft Visual Studio

If you are a college/university student, you can get a free copy from msdnaa if your college or university has affiliation with Microsoft. I have obtained a copy under msdnaa at University of Toronto.

Step #2: How to create a new project in C
Create an empty project. You do this by selecting Visual C++ >> General from the left hand tree in the New Project screen and selecting "Empty Project" From the panel on the right. Then once in the project, right click the source files folder from the tree on the left and "Add Item". Now here it will only give you the choice of creating a .cpp file, do it. Once you have the .cpp file created, you can write straight C in there and it will work fine.

Remember that C++ is actually "C" with classes. So you can write C code in a file with a cpp extension and it will execute as C. You could even rename the file later if you like. As long as it is an empty project you won't be including any extra libraries or frameworks that will flag your C as not legit "C++ code".

Step #3: Compiling in C
Ans: Go to Project and Properties, then somewhere in the myriad of options you'll see "Compile as C++" where you can change it to "Compile as C". And while you're at it, change the source file extension to .c instead of .cpp.

Posted byA nerdy girl at 9:45 PM  

0 comments:

Post a Comment