views:

173

answers:

6

I've decided to dive into some code written in C and I'd like to use VS I have VS08 Pro which I'm using now primarily for C#, but I've noticed that there are no options for C in VS. Also I've noticed that although VS has projects, and whatnot for C++ that the build options are all greyed out so I cannot build C++. What do I need to build C++? Can I add projects and building for C in VS?

+1  A: 

When you install Visual Studio, it offers the different languages as options - perhaps you chose not to install C++?

If that's the case, you'll need to run the installer again.

RichieHindle
A: 

Once you have Visual C++ installed, I believe it can compile C as well. You'll just have a C++ project that doesn't use C++ features. ;D

CrazyJugglerDrummer
+2  A: 

Visual Studio doesn't distinguish much between C++ and C. Instead, you create a C++ project, and then simply add .c files to it. It will by default compile .c files as C code, and .cpp files as C++.

jalf
However like I said in my post VS will not let me compile C++ either.
Unkwntech
A: 

This has already been discussed about the C/C++ compiler in this topic. I wouldn't even bother using Visual Studio 2008 if you're already using 2005 (or for that matter some other compiler/ide) for your C/C++ projects. There's just pretty much no benefits to upgrading your environment from 2005.

David Anderson
Not entirely true, one big benefit of upgrading to vs2008 is that it actually works relatively well in Vista, something that cannot be said of 2005.
Andy J Buchanan
I developed in 2005 on Vista for quite some time, and that was before Service Pack 1. Worked very well, as long as you download all the required updates, which are available via Windows Update.
David Anderson
If nothing else, VS2008 was noticeably snappier than VS2005 for me.
Michael Burr
A: 

To start a new empty C or C++ project in VC++:

File > New > Project... > Visual C++ > Win32 Project > OK > [Application Settings] > [Empty project] > OK

Then add new source file to the project by right clicking on your project name:

Add > New Item... > Visual C++ > Code > C++ File (.cpp) > Add

Just make sure you explicitly give your file a .c extension if you want.

To tell VC++ to compile your whole project as C and not C++, right click on your project name:

Properties > Configuration Properties > C/C++ > Advanced > Compile As > Compile as C Code (/TC) > OK

(That should already be the case for individual file with a .c extension.) You might also check the various other settings is suitable while you're there.

Like RichieHindle said, you might not have installed VC++ during the installation of VS. In that case, you would need to install it before you can do anything obviously. Hope that helps. :)

KTC
Depending on what the C/C++ code does, you might want to create a Console App in stage #1 above.
anon
Yes, I couldn't decide whether I wanted to write "Win32 Project" or "Win32 Console Application" above, but since one can actually change it in "Application Settings", it doesn't really matter.
KTC
+1  A: 

Are you sure you've installed the C++ compiler + related options?

Marcus Lindblom