简体   繁体   English

Eclipse CDT:如何在C源代码上使用GCC C ++编译器?

[英]Eclipse CDT: How to use GCC C++ compiler on C sources?

I have a C++ project in which I need to use some external C sources. 我有一个C ++项目,在其中需要使用一些外部C源代码。 I need to compile them with the same Tool as the project uses: GCC C++ compiler. 我需要使用与项目使用的工具相同的工具来编译它们:GCC C ++编译器。

I Visual Studio there is a setting to set this for each C source: C/C++ -> Advanced -> Compile as C++ Code (/TP). 我在Visual Studio中有一个设置,可以为每个C源设置此设置:C / C ++->高级->编译为C ++代码(/ TP)。

Can I do this with Eclipse CDT ? 我可以使用Eclipse CDT吗?

In project options: 在项目选项中:

  1. You could add -x c++ to the compiler flags: 您可以将-x c++添加到编译器标志中:

    在此处输入图片说明

  2. Alternatively set the tool to g++ instead of gcc 或者将工具设置为g ++而不是gcc

    在此处输入图片说明

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

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