在c++项目中编译不使用预编译头的C文件?

时间:2023-01-03 09:42:58

Can I disable precompile header for .c files in my C++ project?

我可以在我的c++项目中禁用.c文件的预编译头吗?

I'm getting these errors when I want to add the .C files to my program for a scripting virtual/abstract machine which is in C:

当我想将.C文件添加到我的程序中用于C语言的脚本虚拟/抽象机器时,就会出现这些错误:

Error 1 error C1853: 'Release\pluginsa.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa) Z:\Profile\Rafal\Desktop\samod\source\amx\amx.c 1 1 pluginsa

错误1错误C1853:释放\pluginsa。pch'的预编译头文件来自以前版本的编译器,或者预编译头文件是c++,您正在使用它来自C(或相反)Z:\Profile\ \Rafal\ \ \Rafal Desktop\samod\ samod\ \ \ \ \ \ \ \amx\amx \amx)。c 1 1 pluginsa

All other stuff is C++ and uses my precompiled header.

所有其他内容都是c++,并使用我的预编译头。

1 个解决方案

#1


82  

In the Solution Explorer window right click on the *.c file(s) and select Properties. Go to C / C++ -> Precompiled Headers and set the Precompiled Header option to Not Using Precompiled Headers.

在解决方案资源管理器窗口右击*。c文件并选择属性。转到C / c++ ->预编译头文件,并将预编译头文件选项设置为不使用预编译头文件。

Also, unless you actually need precompiled headers, I'd say turn it off project-wide.

另外,除非您确实需要预编译的头文件,否则我建议在整个项目范围内关闭它。

Another option would be to compile your C files as C++ and keep using the precompiled headers. To do that, right click on the project name (or each .c file name), and set C / C++ -> Advanced -> Compiles As to Compile as C++ code.

另一种选择是将C文件编译成c++,并继续使用预编译头文件。为此,右键单击项目名称(或每个. C文件名),设置C / c++ ->高级->编译为c++代码。

#1


82  

In the Solution Explorer window right click on the *.c file(s) and select Properties. Go to C / C++ -> Precompiled Headers and set the Precompiled Header option to Not Using Precompiled Headers.

在解决方案资源管理器窗口右击*。c文件并选择属性。转到C / c++ ->预编译头文件,并将预编译头文件选项设置为不使用预编译头文件。

Also, unless you actually need precompiled headers, I'd say turn it off project-wide.

另外,除非您确实需要预编译的头文件,否则我建议在整个项目范围内关闭它。

Another option would be to compile your C files as C++ and keep using the precompiled headers. To do that, right click on the project name (or each .c file name), and set C / C++ -> Advanced -> Compiles As to Compile as C++ code.

另一种选择是将C文件编译成c++,并继续使用预编译头文件。为此,右键单击项目名称(或每个. C文件名),设置C / c++ ->高级->编译为c++代码。