Difference between *.hxx and *.h header files?

M

Mark Sullivan

What is the difference between the extensions *.hxx and just *.h for header files ?
Can they co-exist?

Mark
 
P

peter koch

What is the difference between the extensions *.hxx and just *.h for header files ?
Can they co-exist?

Mark

Yes, no problem. You can call them whatever you want, and even
a .pascal extension would be fine - for the compiler! I would go for
an established convention of your platform, but would avoid .h as this
to me looks like a C header.

/Peter
 
B

Bart van Ingen Schenau

Mark said:
What is the difference between the extensions *.hxx and just *.h for
header files ? Can they co-exist?

The difference is that one uses a three-letter extension, and the other
a one-letter one. ;-)

As far as a C or C++ compiler is concerned, there is no difference at
all. You could even use something like
*.some_silly_extension_i_like_to_use if you like.
The only thing that the compiler cares about is that it can find a file
with the name you specify and that the file contains syntactically
correct text.

Bart v Ingen Schenau
 
U

Ulrich Eckhardt

Mark said:
What is the difference between the extensions *.hxx and just *.h for
header files ?

There are a few *.h files who's content is defined by some standard. Other
than that, it is only customary (i.e. a convention, not a rule) that hxx
signals C++ header files like cxx is sometimes used for C++ sourcefiles.
However, you will see much more cpp or hpp files.
Can they co-exist?

You can pretty much call your files as you want, neither C nor C++ actually
care much, apart from the few special cases that collide with header files
already used by the languages itself.

Uli
 
P

peter koch

There are a few *.h files who's content is defined by some standard. Other
than that, it is only customary (i.e. a convention, not a rule) that hxx
signals C++ header files like cxx is sometimes used for C++ sourcefiles.
However, you will see much more cpp or hpp files.


You can pretty much call your files as you want, neither C nor C++ actually
care much, apart from the few special cases that collide with header files
already used by the languages itself.

Uli

You have to take care when you give a name already defined by the
standard, but I guess all major platforms will be able to differ so
long as you differentiate using ""-inclusion instead of "<>".

/Peter
 
H

HelloLinux

boost library uses .hpp while standard c library uses .h and standard c
++ library doesn't use any suffix.

They are just convention, and not different.
 
J

Jim Langston

Mark said:
What is the difference between the extensions *.hxx and just *.h for
header files ? Can they co-exist?

The extention of the header files is by convention. You can name a header
file anything you want.

#include "MyFile.bah"

is legal.

I've seen both .h and .hpp used for C++ header files. .H may even be a
likely extion. However, I would suggest you stick with the conventions as
it makes it easier to find things. Easier to search all .h or .h* files for
some specific thing you are looking for then have to guess what extention
the programmer used.
 
A

Aggro

Mark said:
What is the difference between the extensions *.hxx and just *.h for header files ?
Can they co-exist?

There is no difference from the point of view of the C++ which extension
you use. Generally .hxx is used for C++ headers and .h is used for C
headers while many use it for C++ headers also. The content of the file
is more important.
 
D

Default User

Aggro said:
There is no difference from the point of view of the C++ which
extension you use. Generally .hxx is used for C++ headers and .h is
used for C headers while many use it for C++ headers also.

I've never seen .hxx used in real code. I've seen .hpp on occasion.




Brian
 
J

James Kanze

I've never seen .hxx used in real code. I've seen .hpp on occasion.

It was used with some early MS-DOS compilers, I think. At my
clients, .hh has been by far the most widespread, but all of my
clients have been Unix based.
 
D

Default User

James said:
It was used with some early MS-DOS compilers, I think. At my
clients, .hh has been by far the most widespread, but all of my
clients have been Unix based.

I have occasionally seen that, when the source files carry a .cc
extension. Symmetry, I suppose.



Brian
 
S

Shen-Ou YE

Mark said:
What is the difference between the extensions *.hxx and just *.h for header files ?
Can they co-exist?

Mark
Hi

I'm new in this newsgroup and my english is not perfect too so be tolerant.

My use of these files is as follow :
- .h files are used to declare types, classes (templates or not),
prototypes (templates or not and so on
- .hxx are used to implement inline methods, templates classes and
functions.

You include .hxx file at the end of the .h file and in the same way,
include the .h file at the top of the .hxx file. The .c files are used
to implement the rest of the .h files.

So you can split declaration from the implementation and your code is
easier ti maintain and read.

Was I clear enough ? Don't hesitate

Shen
 
J

James Kanze

I have occasionally seen that, when the source files carry a .cc
extension. Symmetry, I suppose.

Yes. In general, the first decision a company makes is whether
C++ header files will use .h, or something different than C. In
the latter case, the ending for the header files will almost
always be the same as that for the source files, with the c
replaced by an h, e.g. .hpp if the sources are .cpp, .hh if the
sources are .cc, etc. The original convention was .C for C++
sources, and I've also seen .H for the headers. This convention
fails , however, under systems which don't distinguish case, and
it seems like everyone who ported C++ to a system which didn't
distinguish case chose something different. Microsoft (and I
think Borland) chose .cpp, and that has become quasi-universel
in the Windows world. I don't know where the .cc originally
came from (maybe the Glockenspiel ports of CFront), but it seems
the most frequent convention in the Unix world (but not nearly
as ubiquious as .cpp under Windows). At any rate, all modern
compiler drivers understand .cpp, .cxx, .cc and .C if the system
supports it to be C++ sources, so it really doesn't matter that
much (although you should be consistent). (You can also specify
the language explicitly with every compiler I've used; VC++ 6.0
didn't recognize .cc, so when I ported some of my Unix code to
it, I simply specified the source file with /Tp in the command
line. Apparently, I'm not the only one who was porting Unix
code to Microsoft, however, since Microsoft added recognition of
.cc with the next version.)
 
J

James Kanze

I'm new in this newsgroup and my english is not perfect too so
be tolerant.

Whose English is perfect (and by what standard)?
My use of these files is as follow :
- .h files are used to declare types, classes (templates or not),
prototypes (templates or not and so on
- .hxx are used to implement inline methods, templates classes and
functions.

This distinction is frequently made; in some cases, template
implementations will also be separated from inline functions, to
facilitate use of export, when it becomes available. The naming
conventions are usually a bit different, however: .ihh was
common for the inline functions, in the past, and .tcc seems
almost universal for template implementations (even in cases
where .cpp/.hpp rules otherwise).
 
F

Fred

What is the difference between the extensions *.hxx and just *.h for header files ?
Can they co-exist?

From a language standpoint, there is no difference. There isn't even
any requirement that they have either of these extensions, or even
hagve an extension.

#include "abc.def"

will work perfectly fine.

".h" is typically used for C include files; ".hxx" for C++
 
J

Jimmy Hartzell

James said:
Yes. In general, the first decision a company makes is whether
C++ header files will use .h, or something different than C. In
the latter case, the ending for the header files will almost
always be the same as that for the source files, with the c
replaced by an h, e.g. .hpp if the sources are .cpp, .hh if the
sources are .cc, etc. The original convention was .C for C++
sources, and I've also seen .H for the headers. This convention
fails , however, under systems which don't distinguish case, and
it seems like everyone who ported C++ to a system which didn't
distinguish case chose something different. Microsoft (and I
think Borland) chose .cpp, and that has become quasi-universel
in the Windows world. I don't know where the .cc originally
came from (maybe the Glockenspiel ports of CFront), but it seems
the most frequent convention in the Unix world (but not nearly
as ubiquious as .cpp under Windows). At any rate, all modern
compiler drivers understand .cpp, .cxx, .cc and .C if the system
supports it to be C++ sources, so it really doesn't matter that
much (although you should be consistent). (You can also specify
the language explicitly with every compiler I've used; VC++ 6.0
didn't recognize .cc, so when I ported some of my Unix code to
it, I simply specified the source file with /Tp in the command
line. Apparently, I'm not the only one who was porting Unix
code to Microsoft, however, since Microsoft added recognition of
.cc with the next version.)

Does anyone use .c++, as in foo.c++? Would this be seen as extremely
weird/advised against?

Granted there are problems on other platforms, but has anyone come
across any problems with .C on Unix? Has anyone had any minor programs
that had case-sensitivity issues that they've run into? What about
e-mailing the sources to other people/attachment names, etc.? Are there
any gotchas to look out for doing that?

Jimmy Hartzell
 
S

sk_usenet

Mark Sullivan said:
What is the difference between the extensions *.hxx and just *.h for
header files ?
Nothing, just a naming difference. People sometime use the *.hpp extension
to emphasize that it's a C++ header.
Can they co-exist?
Yes.
 
J

James Kanze

On 2008-05-19 02:27:17 -0400, James Kanze <[email protected]> said:
Yes, but it was the other way around: Borland started using
.cpp, and when Microsoft got around to C++ three years later,
they followed the established standard.

I knew that Borland had a C++ compiler long before Microsoft
did. I just wasn't sure that they used .cpp. And I'm not sure
that Borland had the weight to make it "the established
standard".

I've just taken a look at some old code that I wrote for the
Zortech C++ compiler---before Borland had C++, even. It uses
.cpp, so the usage of .cpp goes back to before Borland even.
And now I wonder where I saw .cxx---I know I've seen it, and I
think it was under MS-DOS, but if Zortech, Borland and Microsoft
all used .cpp, I don't know who's left. Glockenspiel, maybe?
(And we can "blame" Walter for .cpp:).)
 
J

James Kanze

[...]
Does anyone use .c++, as in foo.c++? Would this be seen as
extremely weird/advised against?

A lot of systems don't allow the + character in filenames. I
wouldn't be too surprised if some shells also used it as a meta
character. For maximum portability, a filename should only
consist of alphanumerics and a single dot, very near the end.
You might risk an '_' or a '-', but that's about it.
Granted there are problems on other platforms, but has anyone
come across any problems with .C on Unix?

No. It was the standard until C++ was ported to MS-DOS (and
doubtlessly other OS's---I think Unix was sort of an exception
in using case sensitive filenames).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top