问题描述
是否可以(以及如何)在 Eclipse CDT,在使用 .hpp/.cpp 模板创建新类时?
Is it possible (and how) to add the namespace in the name of the automatic generated include guards in Eclipse CDT, when creating a new class using the .hpp/.cpp templates?
对我来说,Eclipse 很好地生成了一个带有命名空间的新类,但是包含保护不包含命名空间,所以如果同一个头文件在两个不同的目录中存在两次,则只能包含一个.
For me Eclipse generates a new class with a namespace nicely, but the include guards do not contain the namespace, so if the same header file exists twice in two different directories, only one can be included.
在我的例子中,命名空间的名称、Eclipse 项目名称和源目录的名称都是相同的,因此这些可以作为包含保护的前缀的替代方案.
In my case the name of the namespace, the Eclipse project name and the name of the source directory are all the same, so these could be alternatives as prefix for the include guard.
推荐答案
所以在 C/C++ -> Code Style -> Code Templates 下的 Preferences 对话框中,您可以修改模板以更接近您的需要,例如,如果你需要守卫中的命名空间,你可以做类似的事情.
So in the Preferences dialog under C/C++ -> Code Style -> Code Templates you can modify the template to be closer to what you need, for example if you need the namespace in the guard, you can do something like.
${filecomment}
#ifndef ${namespace_name}_${include_guard_symbol}
#define ${namespace_name}_${include_guard_symbol}
${includes}
${namespace_begin}
${declarations}
${namespace_end}
#endif /* ${namespace_name}_${include_guard_symbol} */`
这篇关于Eclipse-CDT:在自动生成的包含防护中使用命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)