Reputation: 128807
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
.c
files to it. It works but it creates tons of files..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.Upvotes: 4
Views: 28636
Reputation: 99869
Choose C++ File (.cpp), and give it a name like SomeName.c
. Make sure to specify the .c
extension. Add the following code:
int main(int argc, char** argv)
{
return 0;
}
If necessary, disable Microsoft extensions to the C language by right clicking the project and selecting Properties. Select All Configurations at the top of the dialog. Then go to C/C++ → Language → Disable Language Extensions: Yes.
Visual Studio will create the following files for your project. Just get used to having them there. Do not check items with a * into source control.
Upvotes: 9
Reputation: 520
VS actually has a very capable C compiler, somethng that people overlook all too often. The above answers will point you in the right direction, but it's by no means low quality like I've heard people say in the past.
Upvotes: 1
Reputation: 146910
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.
Upvotes: 2