简体   繁体   English

Visual Studio 2010设置

[英]Visual Studio 2010 settings

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. 我正在尝试在Visual Studio 2010中编译一个C ++项目。它包含许多C ++文件,并且还具有几个C文件。

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. 因为它是一个C ++项目,并且警告级别设置为/ W4,所以我在C源代码上收到了很多警告。

Is there a way to select the C compiler for C source code and the C++ compiler for C++ source code? 有没有办法为C源代码选择C编译器,为C ++源代码选择C ++编译器?

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. 如果由于某种原因重写了编译模式,则可以手动设置它:转到C文件的属性。 Inside: Configuration Properties --> C/C++ --> Advanced --> Compile As --> Compile as C code. 内部:配置属性-> C / C ++->高级->编译为->编译为C代码。

Make sure you name your files with the correct extensions. 确保使用正确的扩展名命名文件。

.c files are compiled with the C compiler. .c文件使用C编译器进行编译。

.cpp files are compiled with the C++ compiler. .cpp文件使用C ++编译器进行编译。

There's no template for a C file, just choose C++ file and name it appropriately. C文件没有模板,只需选择C ++文件并适当命名即可。 Otherwise if it is already added to your project, you can still rename the file. 否则,如果已将其添加到项目中,则仍可以重命名该文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM