Search code examples
cvisual-studio-2010development-environmentcompilation

How can I use Visual Studio 2010 for C development?


I would like to do some C development in Windows environment using Visual Studio 2010. There are a few similar questions on this topic, but they are all based on that you are creating a Win32 console application, and a C++ project.

How can I do C development using only .c and .h files as I do in Unix? without creating a C++ projects containing tons of files.

It is possible to do C compiling with the cl compiler from outside of Visual Studio 2010, see Walkthrough: Compiling a C Program. But how can I do this compilation and execution/debugging from inside Visual Studio 2010?

UPDATE

  • I have tried to create a C++ project (Win32 Console Application) and only add .c files to it. It works but it creates tons of files.
  • I have tried with a C++ project (Empty project), but it also created a lot of project files.
  • Basically what I want is to only create .c and .h files, use the cl compiler, and use Visual Studio 2010 as a text editor. And use a command to compile from the text edior, but it seems like I have to compile in a command prompt.

Solution

  • If you compile a file that has the .c extension, VS will use it's C compiler. However, you should be aware that said C compiler isn't C99 conformant (or even C89 for some cases, if I remember correctly). Visual Studio is not really a C compiler, it's C++ mostly. You will have to use a C++ project and simply include .c files.