What is the significance of a .h file?

c, c++, header-files

Solution

The use of .h to name header files is just a convention. You will also see (probably on Unix-like platforms):

- .hpp (the Boost library uses these)

- .hxx (looks like h++ with the + signs tilted - cute, huh?)

- .H (Unix is case sensitive so you can distinguish these from .h files)

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.

Problem

I know that .h file is supposed to have: - class declarations, - function prototypes, - and extern variables (for global variables) 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. `We can name our file to be anything, but we choose to name it as a .h file.` Am I correct?

Original source

Related problems