简体   繁体   English

Eclipse CDT:自动添加头文件

[英]Eclipse CDT: Automatically Add Header File

I'm working through Programming: Principles and Practice Using C++ , and it's recommended/necessary to include a particular header file from the author's site, called std_lib_facilities.h. 我正在研究“ 编程:使用C ++的原理和实践” ,建议/有必要在作者的网站中包括一个名为std_lib_facilities.h的特定头文件。 It's kind of a pain, though, to manually add this file to each project source folder whenever I start a new project. 但是,每当我开始一个新项目时,手动将此文件添加到每个项目源文件夹中是一种痛苦。 Is there some way to have it added to a project folder upon creation? 创建后是否可以通过某种方式将其添加到项目文件夹中?

Here everything is explained How to use an existing Project as a template for a new one with Eclipse (CDT)? 此处说明了所有内容如何使用Eclipse(CDT)将现有项目用作新项目的模板?

Just create a new project in Eclipce C++. 只需在Eclipce C ++中创建一个新项目即可。 It can be "Hello, world" project from CDT templates. 它可以是CDT模板中的“ Hello,world”项目。 Then edit source file, add #include "std_lib_facilities.h" and add std_lib_facilities.h itself to the folder (for example src folder). 然后编辑源文件,添加#include“ std_lib_facilities.h”并将std_lib_facilities.h本身添加到文件夹(例如src文件夹)。 Then save everything and do not change it anymore. 然后保存所有内容,不再更改。 It will be yout Base project for all future projects. 这将是所有未来项目的基础项目。

After that every time you need create another project with std_lib_facilities.h included in ProjectExplorer panel or in C/C++Projects panel press "Copy" and then "Paste". 之后,每次您需要使用ProjectExplorer面板或C / C ++ Projects面板中包含的std_lib_facilities.h创建另一个项目时,请按“复制”,然后按“粘贴”。 You will be asked for a name of new project and then all files will be copied. 系统将要求您输入新项目的名称,然后将复制所有文件。

That is it. 这就对了。

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

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