4

Not C++, not C#, just plain old C for my computer science class.

I see options for C#, F#, Visual Basic, and Visual C++, but if there's an easy way to get it to work with C, I'm not seeing it.

*"set up as an IDE" in this case, meaning use Visual Studio to compile, debug, and run the written programs via VS2010, just as I've been using it previously for programming in c#.

3 Answers 3

5

Nothing special is needed. Just write your code in a .c source code file instead of a .cpp file. The project templates create .cpp files, just rename them with right-click + Rename.

1
  • +1: Just for completeness you can also instruct the compiler to compile a .cpp file as C code by right clicking on it in the project explorer.
    – torak
    Aug 26, 2010 at 18:38
3

Create an empty C++ project.

Bring up the project's properties by right clicking on it in the solution explorer and selecting "Properties".

Browse to Configuration Properties -> C/C++ -> Advanced.

Switch the Compile As property to "Compile as C Code (/TC)". This will compile all source files as C.

See also the /TC compiler option: http://msdn.microsoft.com/en-us/library/032xwy55%28v=VS.71%29.aspx.

2

Just give your files names with .c extension, an they will be compiled as C. Alternatively, you can specify that a particular file should be compiled as C (regardless of the file name extension) in the project settings. Nothing else needs to be done.

Note though that one annoyance of this IDE is that its syntax highlighting (and some other) features are tailored for C++. It will highlight C++-specific keywords in C code, which is rather annoying. Features like IntelliSense also fail to work properly with C++ -specific keywords in C code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.