Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to develop C with Visual Studio 2010?

Is there a way to develop pure ANSI C with Visual Studio 2010?

like image 386
Jeff Avatar asked Apr 24 '11 13:04

Jeff


People also ask

Can you develop C in Visual Studio?

The Visual Studio build tools include a C compiler that you can use to create everything from basic console programs to full Windows Desktop applications, mobile apps, and more.

How do I start coding C in Visual Studio?

Prerequisites for running a C program in Visual Studio CodeDownload the C/C++ Extension. It is an extension provided by Microsoft that support visual studio code. It helps in IntelliSence, debugging and code browsing of the programming code in the visual studio. Download the C/C++ compilers.

How do I create a new C project in Visual Studio?

Open Visual Studio, and choose Create a new project in the Start window. In the Create a new project window, select All languages, and then choose C# from the dropdown list. Choose Windows from the All platforms list, and choose Console from the All project types list.


2 Answers

Yes, it's possible. MSDN provides some information here: ANSI C Compliance.

Step one is setting the compiler to produce C code, rather than C++ code. Do that from your project's Properties. Expand the C/C++ header, and click on "Advanced". Set the "Compile As" property to "Compile as C Code" (this is the same as specifying the /TC switch on the command line). Even easier is to just name your files with a *.c extension.

Step two is disabling Microsoft's extensions to the ANSI standards. These are governed by the /Za and /Ze compiler switches. You can find these in your project's Properties, as well. /Za causes the compiler to emit an error for language constructs that are not compliant with the ANSI standard. The /Ze switch enables Microsoft-specific extensions; you want to make sure that this one is turned off.

Although I don't believe that Microsoft fully supports the C99 standard. See (and vote for!) this bug report on MS Connect, this blog entry from the VC++ team, and this page for a concrete example of where that lack of support becomes evident. It does, however, have full support for the C90 standard.

like image 159
Cody Gray Avatar answered Sep 21 '22 13:09

Cody Gray


Via changing the file extension to .c will get you started but here are also some changes to the project file. See here for details: http://support.microsoft.com/kb/829488/en-us

There is also a good podcast on that: http://channel9.msdn.com/Blogs/Sam/C-Language-Programming-with-Visual-Studio-2010-Ultimate-Pro-or-VC-Express

like image 33
Teoman Soygul Avatar answered Sep 21 '22 13:09

Teoman Soygul