C on Visual Studio

C programming in Visual Studio

Short answer: Yes, you need to rename .cpp files to c, so you can write C:
https://msdn.microsoft.com/en-us/library/bb384838.aspx?f=255&MSPPError=-2147217396

From the link above:

By default, the Visual C++ compiler treats all files that end in .c as C source code, and all files that end in .cpp as C++ source code. To force the compiler to treat all files as C regardless of file name extension, use the /Tc compiler option.

That being said, I do not recommend learning C language in Visual Studio, why VS? It does have lots of features you are not going to use while learning C

C on Visual Studio

Answering the purely subject question "recommend me a better C IDE and compiler" I find Ming32w and Code::blocks (now with combined installer) very useful on windows but YMMV as you are obviously used to the MS IDE and are just struggling with C.

May I suggest you concentrate on console applications to get a feel for the language first before you attempt to tie it together with a windows UI which in my experience is the hardest bit of windows development.

How to run C program in Visual Studio (Mac)

Before trying to compile, the C environment (all the include headers, libraries, etc) has to be installed.

this web page should be of great help to you:

https://www.tutorialspoint.com/cprogramming/c_environment_setup.htm

especially the paragraph:

Installation on Mac OS

If you use Mac OS X, the easiest way to obtain GCC is to download the Xcode development environment from Apple's web site and follow the simple installation instructions.
Once you have Xcode setup, you will be able to use GNU compiler for C/C++.

Xcode is currently available at

developer.apple.com/technologies/tools/

Visual Studio: Create a Hello World app in C?

Visual Studio doesn't have a separate compiler for C, it uses the C++ compiler for C code. You can tell it to restrict itself to legal C syntax by using a compiler switch or by renaming the .cpp file to .c

Edit: I'm still using 2005 on this machine, so it might not be in the same place, but try this

  • Right click on the main.cpp in the solution explorer pane (on the right).
  • Choose Properties (bottom of the menu)
  • Open up the C/C++ group of properties
  • choose Advanced page
  • Change "Compile As" property to "Compile as C Code (/TC)"


Related Topics



Leave a reply



Submit