C ++:为什么使用".hh"作为C ++头文件的扩展名 [英] C++: Reason why using ".hh" as extension for C++ header files

查看:158
本文介绍了C ++:为什么使用".hh"作为C ++头文件的扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道为什么我们使用".hh"作为C ++头文件的扩展名,而不是仅仅使用".h".

I would like to know why we use ".hh" as extension for C++ header files instead of using just ".h".

头文件已经过预处理,预处理器甚至不在乎头文件的扩展名.因此,即使我创建了带有扩展名".qwe"(test.qwe)的头文件.然后,为什么要使用".hh"作为C ++头文件的扩展名.

The header files are preprocessed and the preprocessor doesn't even care about the extension of the header file. So, even if I create a header file with an extension ".qwe" (test.qwe). Then, why to use ".hh" as extension for C++ header files.

有人说,我们使用".cc"作为C ++文件的扩展名以区别于C文件(其扩展名为".c"),同样,我们也使用".hh"作为C ++头文件的扩展名,与C头文件(扩展名为".h")有所区别.我认为这不是正当的理由.

Some say, we are using ".cc" as extension for C++ files to differentiate from C files (which has an extension ".c"), likewise we are using using ".hh" as extension for C++ header files to differentiate from C header files (which has an extension ".h"). I don't think this to be a valid reason.

有人知道这样命名的原因吗?

Does anyone know the reason for naming in such a way?

推荐答案

有人说,我们使用".cc"作为C ++文件的扩展名,以区别于C文件(具有扩展名".c"),同样,我们使用".hh"作为C ++的扩展名头文件,以区别于C头文件(扩展名为".h").

这正是原因.只是为了区分CPP标头和C标头.

That is exactly the reason. It is just to differentiate CPP headers from C headers.

某些编程器和库(例如Boost)将.hpp用作CPP标头.我个人的选择是:

Some programmers and libraries, such as Boost, use .hpp for CPP headers. My personal choice is this:

  • example.c
  • example.cpp
  • example.h
  • example.h ++

即使它们都属于一个巨大的项目,您仍然可以弄清楚哪个是哪个.无需描述.

Even if they all belong to a huge project, you can still figure out which one is which. No description is needed.

这篇关于C ++:为什么使用".hh"作为C ++头文件的扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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