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

Discussion in 'C++' started by Mark Sullivan, May 17, 2008.

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

    Mark
     
    Mark Sullivan, May 17, 2008
    #1
    1. Advertising

  2. Christian Hackl, May 17, 2008
    #2
    1. Advertising

  3. Mark Sullivan

    peter koch Guest

    On 17 Maj, 17:12, (Mark Sullivan) wrote:
    > 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
     
    peter koch, May 17, 2008
    #3
  4. Mark Sullivan wrote:

    > 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.

    >
    > Mark


    Bart v Ingen Schenau
    --
    a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
    c.l.c FAQ: http://c-faq.com/
    c.l.c++ FAQ: http://www.parashift.com/c -faq-lite/
     
    Bart van Ingen Schenau, May 17, 2008
    #4
  5. Mark Sullivan wrote:
    > 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
     
    Ulrich Eckhardt, May 17, 2008
    #5
  6. Mark Sullivan

    peter koch Guest

    On 17 Maj, 20:06, Ulrich Eckhardt <> wrote:
    > Mark Sullivan wrote:
    > > 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


    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
     
    peter koch, May 17, 2008
    #6
  7. Mark Sullivan

    HelloLinux Guest

    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.

    Mark Sullivan wrote:
    > What is the difference between the extensions *.hxx and just *.h for header files ?
    > Can they co-exist?
    >
    > Mark
     
    HelloLinux, May 17, 2008
    #7
  8. Mark Sullivan

    Jim Langston Guest

    Mark Sullivan wrote:
    > 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.


    --
    Jim Langston
     
    Jim Langston, May 18, 2008
    #8
  9. Mark Sullivan

    Aggro Guest

    Mark Sullivan wrote:
    > 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.
     
    Aggro, May 18, 2008
    #9
  10. Mark Sullivan

    Default User Guest

    Aggro wrote:

    > Mark Sullivan wrote:
    > > 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.


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




    Brian
     
    Default User, May 18, 2008
    #10
  11. Mark Sullivan

    James Kanze Guest

    On 18 mai, 20:18, "Default User" <> wrote:
    > Aggro wrote:
    > > Mark Sullivan wrote:
    > > > 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.


    > 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.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, May 18, 2008
    #11
  12. Mark Sullivan

    Default User Guest

    James Kanze wrote:

    > On 18 mai, 20:18, "Default User" <> wrote:
    > > Aggro wrote:


    > > > 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.

    >
    > 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
     
    Default User, May 18, 2008
    #12
  13. Mark Sullivan

    Shen-Ou YE Guest

    Mark Sullivan wrote:
    > 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
     
    Shen-Ou YE, May 19, 2008
    #13
  14. Mark Sullivan

    James Kanze Guest

    On 19 mai, 00:16, "Default User" <> wrote:
    > James Kanze wrote:
    > > On 18 mai, 20:18, "Default User" <> wrote:
    > > > Aggro wrote:
    > > > > 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.


    > > 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.


    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.)

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, May 19, 2008
    #14
  15. Mark Sullivan

    James Kanze Guest

    On 19 mai, 02:34, Shen-Ou YE <> wrote:
    > Mark Sullivan wrote:
    > > What is the difference between the extensions *.hxx and just
    > > *.h for header files ? Can they co-exist?


    > 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).

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, May 19, 2008
    #15
  16. Mark Sullivan

    Fred Guest

    On May 17, 8:12 am, (Mark Sullivan) wrote:
    > 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++

    --
    Fred K
     
    Fred, May 19, 2008
    #16
  17. James Kanze wrote:
    > On 19 mai, 00:16, "Default User" <> wrote:
    >> James Kanze wrote:
    >>> On 18 mai, 20:18, "Default User" <> wrote:
    >>>> Aggro wrote:
    >>>>> 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.

    >
    >>> 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.

    >
    > 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
     
    Jimmy Hartzell, May 19, 2008
    #17
  18. Mark Sullivan

    sk_usenet Guest

    "Mark Sullivan" <> wrote in message
    > 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.

    --
    http://techytalk.googlepages.com
     
    sk_usenet, May 19, 2008
    #18
  19. Mark Sullivan

    James Kanze Guest

    On May 19, 1:04 pm, Pete Becker <> wrote:
    > On 2008-05-19 02:27:17 -0400, James Kanze <> said:


    > > Microsoft (and I think Borland) chose .cpp, and that has
    > > become quasi-universel in the Windows world.


    > 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:).)

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, May 20, 2008
    #19
  20. Mark Sullivan

    James Kanze Guest

    On May 19, 11:07 pm, Jimmy Hartzell <> wrote:

    [...]
    > 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).

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, May 20, 2008
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jakk
    Replies:
    4
    Views:
    12,647
  2. John Smith

    Header files included in header files

    John Smith, Jul 21, 2004, in forum: C Programming
    Replies:
    18
    Views:
    639
    Jack Klein
    Jul 24, 2004
  3. Patrick Brehmer
    Replies:
    9
    Views:
    6,598
    $B3Y?.L@(B
    Dec 5, 2008
  4. mlt
    Replies:
    2
    Views:
    917
    Jean-Marc Bourguet
    Jan 31, 2009
  5. whit
    Replies:
    1
    Views:
    629
    James Kanze
    Mar 19, 2009
Loading...

Share This Page