什么是.h文件的意义何在? [英] What is the significance of a .h file?
本文介绍了什么是.h文件的意义何在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道.h文件中应该有:
I know that .h file is supposed to have:
- 类的声明,
- 函数原型,
- 和extern变量(全局变量)
但有使其成为 .H
文件的某些意义?
我试图重新命名我的 .H
文件到 .C
文件,它仍然有效。
But is there some significance of making it a .h
file?
I tried renaming my .h
file to a .c
file and it still works.
我们可以命名我们的文件是什么,但我们选择其命名为.h文件。
我是正确的?
推荐答案
要名头文件使用的.h的仅仅是一个惯例。你还会看到(可能在类Unix平台):
The use of .h to name header files is just a convention. You will also see (probably on Unix-like platforms):
- .HPP(Boost库使用这些)
- .HXX(貌似^ h +与+的迹象倾斜 - 可爱的,是吧?)
- .H(在Unix是大小写敏感的,因此您可以区分这些从.h文件)
个人而言,我强烈建议用.H坚持。特别是,不要使用.H,或者你会在痛苦的世界,如果你在任何时候需要移植到不区分大小写的文件系统。
Personally, I'd strongly advise sticking with .h. Particularly, don't use .H, or you will be in a world of pain if you ever need to port to case-insensitive file system.
这篇关于什么是.h文件的意义何在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文