From:http://stackoverflow.com/questions/152555/h-or-hpp-for-your-class-definitions I use .hpp because I want the user to differenciate what headers are C++ headers, and what headers are C headers.
This can be important when your project is using both C and C++ modules: Like someone else explained before me, you should do it very carefully, and its starts by the “contract” you offer through the extension
.hpp : C++ Headers (Or .hxx, or .hh, or whatever)
This header is for C++ only.
If you’re in a C module, don’t even try to include it. You won’t like it, because no effort is done to make it C-friendly (too much would be lost, like function overloading, namespaces, etc. etc.).
.h : C/C++ compatible or pure C Headers This header can be included by both a C source, and a C++ source, directly or indirectly.
It can included directly, being protected by the __cplusplus macro:
Which mean that, from a C++ viewpoint, the C-compatible code will be defined as extern “c”. From a C viewpoint, all the C code will be plainly visible, but the C++ code will be hidden (because it won’t compile in a C compiler). For example:
#ifdef __cpluplus extern “C” { #endif
void myCFunction() ;
#ifdef __cpluplus } // extern “C” #endif
Or it could be included indirectly by the corresponding .hpp header enclosing it with the extern “c” declaration.
For example:
extern “C” {
}
and:
void myCFunction() ;