Reputation: 6285
I am trying to compile a C++ project in Visual Studio 2010. It contains many C++ files and it also has a couple of C files.
Because it is a C++ project and the warning level is set to /W4 I am getting a lot of warnings on the C source code.
Is there a way to select the C compiler for C source code and the C++ compiler for C++ source code?
Upvotes: 0
Views: 105
Reputation: 18368
Normally, the file extension will be used to hint a default compilation mode. If for some reason the compilation mode was overriden, you can set it manually: Go to properties of your C file. Inside: Configuration Properties --> C/C++ --> Advanced --> Compile As --> Compile as C code.
Upvotes: 1
Reputation: 134611
Make sure you name your files with the correct extensions.
.c
files are compiled with the C compiler.
.cpp
files are compiled with the C++ compiler.
There's no template for a C file, just choose C++ file and name it appropriately. Otherwise if it is already added to your project, you can still rename the file.
Upvotes: 0