On 2008-11-27 20:44, Patrick Brehmer wrote:
Which is probably what most people use.
I don't know about that. Every place I've worked has kept .h
for C headers, and used .hh for C++ (and .cc for the source
files). Under Windows, what little I've seen it was .hpp for
C++ headers, and .cpp for source files. (And back under MS-DOS,
there was also some .hxx and .cxx. And the original C++
implementations used .C for the source files.)
The C pre-processor (which is very similar to the C++
pre-processor) is also commonly referred to as CPP which might
cause some confusion in certain circumstances (especially if
you output the pre-processed files with .cpp as suffix), which
might be one reason to use .cxx/.hxx.
Some people also make a distinction between .h and .hpp where
the latter is used for templates, i.e. they do not just
contain the interface, but also the implementation.
No. The distinction is that a .h file can be used in a C
program; a .hpp can't. When template implementations are kept
separate, they usually receive a different suffix entirely; I've
seen .tcc in several contexts. (And in earlier times, I've seen
..ihh for the implementation of inline functions.)
Yes, but I would recommend that you choose one convention and
use it for all files, and unless you have any reason not to I
think .cpp/.h is the best.
Unless you're really a 100% Windows shop, I think you're going
to have to deal with different conventions, because different
third party libraries will use different conventions. I use
..hh/.cc, because that is what my customers do; globally, I
suspect that .hpp/.cpp is more widely used, however.
One thing is certain, however: you don't want to use .h unless
the header can be used in a C program.