What's the difference between C header files (.h) and C++ header files (.hpp)?

Just convention, nothing special. You can use any extension on include files, actually.


.hpp, .H, etc. is a loose convention for C++ header files, .tcc is a loose convention for C++ template implementation, .h is pretty strong convention for c files.

Boost uses hpp extension, QT uses .h extension, STL do not have extension. I am sure there are libraries which use .H but have not seen any.


Indeed, Otavio is correct.

I use hpp / h to differentiate between the two languages when building mixed-language products. For example, a class definition might go in a .hpp (implementation in .cpp), whereas a .h file would define only functions supported by C. To do this separation it is important to know the difference between the languages - to this end I pass *.c through gcc and *.cpp through g++.

Tags:

C++

C