C ++模板实现文件扩展约定? [英] C++ Template implementation file extension convention?

查看:74
本文介绍了C ++模板实现文件扩展约定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于模板类实现使用什么文件扩展名是否存在约定? **。tpp .template .hpp **

Is there a convention for what file extension is used for template class implementation? **.tpp .template .hpp **

推荐答案


用于模板类实现的文件扩展名是什么?

没有真正的标准约定可用于这些文件扩展名是AFAIK。

No there isn't really a standard convention established for these file extensions AFAIK.

虽然有一些常用的文件扩展名,例如

There's a number of file extensions commonly used though, like


  • .icc

  • .inl

  • .tcc (似乎至少是我的GCC 4.8.1标准库实现所使用的)

  • ...

  • .icc
  • .inl
  • .tcc (which seems at least to be used by my GCC 4.8.1 standard libraries implementation)
  • ...

这并不重要,因为您只需使用 #include MyImpl.tcc #include MyImpl.tpp 对其进行明确说明模板头文件中的语句。

It doesn't really matter that much, because you'll need to be explicit about it with the #include "MyImpl.tcc", #include "MyImpl.tpp" statement in the template header file anyway.

例如,您可以使用 .tci t emplate c 实现 i ,这是我在这里动态地发明的;-))

You could use for instance .tci (template class implementation, one I've invented creatively on the fly here ;-) )

重要的一点是,您应该在解决方案涉及的所有项目中使用一致的命名策略(这将使您更容易设置IDE首选项以突出显示语法)。

One important point is, you should use a consistent naming strategy over all of your projects involved to the solution (This would make it even easier to set up you IDE preferences for syntax highlighting).

恕我直言,唯一的 扩展名是 .cc .cpp .cxx .c ,这会使大多数自动当前正在构建系统和IDE。构建系统将假定这些文件需要作为其他对象进行构建和链接,并且由于这些文件无法独立构建或最终以链接中的多个符号定义而失败。

The only no go extensions IMHO are .cc, .cpp, .cxx and .c, which would confuse most of the automated build systems and IDE's currently around. The build system will assume these files need to be to build and linked as additional objects, and fail because of these either can't be build standalone, or ending up with multiple symbol definitions in linkage.

这篇关于C ++模板实现文件扩展约定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆