是否可以(以及如何)在 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模板网!
将 window tester 与 eclipse 集成以测试 UIIntegrate window tester with eclipse for testing UI(将 window tester 与 eclipse 集成以测试 UI)
如何将特定键绑定到 Eclipse 中的不同启动配置?How can I bind a specific key to different launch configurations in Eclipse?(如何将特定键绑定到 Eclipse 中的不同启动配置?)
使用屏幕键盘键入时,Android 中的 EditText 不显示EditText in Android doesn#39;t show text when typing while using the on-screen keyboard(使用屏幕键盘键入时,Android 中的 EditText 不显示文
Kivy、Eclipse 和 PyDev(也是 PyPy)Kivy, Eclipse and PyDev (also PyPy)(Kivy、Eclipse 和 PyDev(也是 PyPy))
Java XPath:使用默认命名空间 xmlns 进行查询Java XPath: Queries with default namespace xmlns(Java XPath:使用默认命名空间 xmlns 进行查询)
Eclipse/Java - 导入 java.(namespace).* 有害吗?Eclipse/Java - is it harmful to import java.(namespace).*?(Eclipse/Java - 导入 java.(namespace).* 有害吗?)