Topic: Header Files - *.h or *.hpp


Author: dave@boost-consulting.com (David Abrahams)
Date: Mon, 24 Mar 2003 23:30:20 +0000 (UTC)
Raw View
nomail@nomail.com ("Mark J") writes:

> Is there anything in the standard about naming convention for header files?
> What is the accepted naming convention (ie. *.h or *.hpp)?
>
> Thoughts?

I like *.hpp because my primary C++ source files are *.cpp and it's
easy to search for all C++ sources by looking for *.*pp.  It's a
really simple reason, but it makes a big difference in my life ;-)

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: ron@sensor.com ("Ron Natalie")
Date: Tue, 25 Mar 2003 19:07:36 +0000 (UTC)
Raw View
"James Kanze" <kanze@alex.gabi-soft.fr> wrote in message news:86r88z3ekv.fsf@alex.gabi-soft.fr...

> I  don't think a conforming implementation of C++ can be written where
> the compiler doesn't have a disk or something similar.  (The compiled
> code, of course, may not require such.)

Well, IBM tried to do away with files.   Of course this ended up being
non-compliant because ordering info got lost.



---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: allan_w@my-dejanews.com (Allan W)
Date: Wed, 26 Mar 2003 22:45:18 +0000 (UTC)
Raw View
kanze@alex.gabi-soft.fr (James Kanze) wrote
> (I'm rather
> surprised at the 8+1 restriction.  I've worked on machines which only
> allowed 6 characters before the point, but never one which didn't
> allow at least 3 after.  I would have expected 6+3 as the lowest
> common denominator.)

Were you referring to something I wrote? I've also used a 6+3
system (DEC RSTS/E), but I don't think I've ever used an anyting+1
system... If I said otherwise, I didn't mean it.

> Finally, it isn't really a question of what the implementations
> accept, but what they treat as signifiant.  MS-DOS would have accepted
> a .porno, but wouldn't have distinguished between .POR .porno et
> .porticule.

Right -- case-insensitive, and only 3 characters after the period.
Which caused problems when porting to Windows 95, because files could
now be both synonyms and unique, depending on the program mode -- a
concept that was invisible to the program user.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: kanze@gabi-soft.de (James Kanze)
Date: Thu, 27 Mar 2003 22:41:53 +0000 (UTC)
Raw View
allan_w@my-dejanews.com (Allan W) wrote in message
news:<7f2735a5.0303251953.7f062fac@posting.google.com>...
> kanze@alex.gabi-soft.fr (James Kanze) wrote
> > (I'm rather surprised at the 8+1 restriction.  I've worked on
> > machines which only allowed 6 characters before the point, but never
> > one which didn't allow at least 3 after.  I would have expected 6+3
> > as the lowest common denominator.)

> Were you referring to something I wrote? I've also used a 6+3 system
> (DEC RSTS/E), but I don't think I've ever used an anyting+1
> system... If I said otherwise, I didn't mean it.

I was referring to what the standard guarantees.

> > Finally, it isn't really a question of what the implementations
> > accept, but what they treat as signifiant.  MS-DOS would have
> > accepted a .porno, but wouldn't have distinguished between .POR
> > .porno et .porticule.

> Right -- case-insensitive, and only 3 characters after the period.
> Which caused problems when porting to Windows 95, because files could
> now be both synonyms and unique, depending on the program mode -- a
> concept that was invisible to the program user.

Nothing new.  Early Unixes truncated after 14 characters, so that
verylongfilename.c and verylongfilename referred to the same file.  And
guess what the command:

    cc -o verylongfilename verylongfilename.c

did.

--
James Kanze             GABI Software             mailto:kanze@gabi-soft.fr
Conseils en informatique orient   e objet/
                           Beratung in objektorientierter Datenverarbeitung
11 rue de Rambouillet, 78460 Chevreuse, France, T   l. : +33 (0)1 30 23 45 16

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: llewelly.at@xmission.dot.com (LLeweLLyn)
Date: Fri, 21 Mar 2003 18:56:46 +0000 (UTC)
Raw View
kanze@gabi-soft.de (James Kanze) writes:

> allan_w@my-dejanews.com (Allan W) wrote in message
> news:<7f2735a5.0303181326.42950e26@posting.google.com>...
>=20
>     [...]
> > From a language point of view, the header file is identified with a
> > header-name. The standard doesn't say anything about either an
> > "extension" or a "filetype." It does say that if the header-name
> > includes either the ' or \ character, or either of the character
> > sequences /* or //, that the behavior is undefined (but shouldn't thi=
s
> > be implementation-defined?)
>=20
> Or if it contains more than one '.'.  Or more than eight characters
> before the . or more than 3 after.  At least, these were the rules for
> C.  In C++, =A716.2/5:
>=20
>     The mapping between the delimited sequence and the external source
>     file name is implementation-defined.  The implementation provides
>     unique mappings for sequences consisting of one or more nondigits
>     (2.10) followed by a period (.) and a single nondigit.

Single nondigit? Does that mean .hpp, .hh, .hxx, .h++ are not
    guaranteed to have unique mappings? (where as .h is?)

>     The
>     implementation may ignore the distinctions of alphabetical case.
[snip]

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: ron@sensor.com ("Ron Natalie")
Date: Fri, 21 Mar 2003 20:49:57 +0000 (UTC)
Raw View
"LLeweLLyn" <llewelly.at@xmission.dot.com> wrote in message news:m17katp45r.fsf@localhost.localdomain...
kanze@gabi-soft.de (James Kanze) writes:


> Single nondigit? Does that mean .hpp, .hh, .hxx, .h++ are not
>    guaranteed to have unique mappings? (where as .h is?)

Precisely.



---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: allan_w@my-dejanews.com (Allan W)
Date: Fri, 21 Mar 2003 21:22:42 +0000 (UTC)
Raw View
kanze@gabi-soft.de (James Kanze) wrote

> I'm curious as to why the differences: C allows digits (except for the
> first character), C++ doesn't.  C restricts the significant length to 8,
> C++ requires (apparently) an infinite significant length (which of
> course isn't implementable).

So am I! Thanks for pointing it out; I wasn't aware of the difference.

> allan_w@my-dejanews.com (Allan W) wrote
> > On the other hand, many C++ compilers come bundled into a language
> > processing system, along with an editor, debugger, platform-specific
> > libraries, and so on. I'm reasonably sure that there aren't any
> > platforms that cannot accept .porno files
>
> I've used several.

This seems strange in light of your subsequent remarks:

> It's quite frequent to use a different suffix for files containing
> inline functions or template implementations, witness Boost's .tcc
> (which I'm gradually adopting).  I've also used .mcc and .mhh for
> machine dependant code, the xxx.cc includes xxx.mcc, which is found in a
> platform dependant directory (specified by a -I option when compiling).
> When I still used inline functions, I put them in a .ihh.  And I
> occasionally use a .lhh for local headers.

So your current platform allows .tcc, .mcc, .mhh, .cc, .mcc, .ihh, and
.lhh -- but not .porno? Seems strange -- certainly with all that great
variety, it ought to accept any suffix you want to use.

Is this due to a 3-character limit after the period? I put up with
this limitation for many years on DEC Vax and on MS-DOS/Windows 3.x.
But are there major OS's still in general use that have this limitation?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: allan_w@my-dejanews.com (Allan W)
Date: Sat, 22 Mar 2003 04:09:01 +0000 (UTC)
Raw View
llewelly.at@xmission.dot.com (LLeweLLyn) wrote
> kanze@gabi-soft.de (James Kanze) writes:
> >     The mapping between the delimited sequence and the external source
> >     file name is implementation-defined.  The implementation provides
> >     unique mappings for sequences consisting of one or more nondigits
> >     (2.10) followed by a period (.) and a single nondigit.
>
> Single nondigit? Does that mean .hpp, .hh, .hxx, .h++ are not
>     guaranteed to have unique mappings? (where as .h is?)

I don't think that they're ever "guaranteed" to have unique mappings.
Think of a system without a hard drive, compiling C++ source from
magnetic tape or punch cards.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: kanze@alex.gabi-soft.fr (James Kanze)
Date: Sat, 22 Mar 2003 19:15:01 +0000 (UTC)
Raw View
allan_w@my-dejanews.com (Allan W) writes:

|>  kanze@gabi-soft.de (James Kanze) wrote

|>  > I'm curious as to why the differences: C allows digits (except
|>  > for the first character), C++ doesn't.  C restricts the
|>  > significant length to 8, C++ requires (apparently) an infinite
|>  > significant length (which of course isn't implementable).

|>  So am I! Thanks for pointing it out; I wasn't aware of the
|>  difference.

|>  > allan_w@my-dejanews.com (Allan W) wrote
|>  > > On the other hand, many C++ compilers come bundled into a
|>  > > language processing system, along with an editor, debugger,
|>  > > platform-specific libraries, and so on. I'm reasonably sure
|>  > > that there aren't any platforms that cannot accept .porno
|>  > > files

|>  > I've used several.

|>  This seems strange in light of your subsequent remarks:

|>  > It's quite frequent to use a different suffix for files
|>  > containing inline functions or template implementations, witness
|>  > Boost's .tcc (which I'm gradually adopting).  I've also used
|>  > .mcc and .mhh for machine dependant code, the xxx.cc includes
|>  > xxx.mcc, which is found in a platform dependant directory
|>  > (specified by a -I option when compiling).  When I still used
|>  > inline functions, I put them in a .ihh.  And I occasionally use
|>  > a .lhh for local headers.

|>  So your current platform allows .tcc, .mcc, .mhh, .cc, .mcc, .ihh,
|>  and .lhh -- but not .porno? Seems strange -- certainly with all
|>  that great variety, it ought to accept any suffix you want to use.

My current platform accepts just about anything (up to around 512
characters, anyway).  I have used platforms in the past, however,
which didn't accept more than three characters after the '.'.

|>  Is this due to a 3-character limit after the period? I put up with
|>  this limitation for many years on DEC Vax and on MS-DOS/Windows
|>  3.x.  But are there major OS's still in general use that have this
|>  limitation?

I don't know.  Currently, I work on very few platforms: mainly
Solaris, with a bit of Linux at home.  But I've seen so many different
things in the past that nothing would surprise me.  (I'm rather
surprised at the 8+1 restriction.  I've worked on machines which only
allowed 6 characters before the point, but never one which didn't
allow at least 3 after.  I would have expected 6+3 as the lowest
common denominator.)

Finally, it isn't really a question of what the implementations
accept, but what they treat as signifiant.  MS-DOS would have accepted
a .porno, but wouldn't have distinguished between .POR .porno et
.porticule.

Interestingly, special handling would be needed for the older Unix
systems.  Basically, they had a maximum filename length of 14, but the
'.' was in no way special.  So two names like "thisIsAVeryLongName.h"
and "thisIsAVeryLongName.c" would have mapped to the same filename
unless the compiler did something to prevent it.

--=20
James Kanze                                  mailto:kanze@gabi-soft.fr
Conseils en informatique orient=E9e objet/
                      Beratung in objektorientierter Datenverarbeitung
11 rue de Rambouillet, 78460 Chevreuse, France  Tel. +33 1 41 89 80 93

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: kanze@alex.gabi-soft.fr (James Kanze)
Date: Mon, 24 Mar 2003 23:29:43 +0000 (UTC)
Raw View
allan_w@my-dejanews.com (Allan W) writes:

|>  llewelly.at@xmission.dot.com (LLeweLLyn) wrote
|>  > kanze@gabi-soft.de (James Kanze) writes:
|>  > >     The mapping between the delimited sequence and the
|>  > >     external source file name is implementation-defined.  The
|>  > >     implementation provides unique mappings for sequences
|>  > >     consisting of one or more nondigits (2.10) followed by a
|>  > >     period (.) and a single nondigit.

|>  > Single nondigit? Does that mean .hpp, .hh, .hxx, .h++ are not
|>  > guaranteed to have unique mappings? (where as .h is?)

|>  I don't think that they're ever "guaranteed" to have unique
|>  mappings.  Think of a system without a hard drive, compiling C++
|>  source from magnetic tape or punch cards.

Names in the format 8 + 1 are required to have unique mappings as long
as 1) the characters are all alpha, and 2) they differ in more than
just case.  (The standard doesn't say it, but I presume that they must
also be contained in the basic character set for the unique mapping
guarantees to hold.  I don't think it was the intent to guarantee,
e.g. accented characters, even specified by means of a universal
character name).

I don't think a conforming implementation of C++ can be written where
the compiler doesn't have a disk or something similar.  (The compiled
code, of course, may not require such.)

--=20
James Kanze                                  mailto:kanze@gabi-soft.fr
Conseils en informatique orient=E9e objet/
                      Beratung in objektorientierter Datenverarbeitung
11 rue de Rambouillet, 78460 Chevreuse, France  Tel. +33 1 41 89 80 93

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: robertklarer@yahoo.ca (Robert Klarer)
Date: Mon, 31 Mar 2003 05:42:09 +0000 (UTC)
Raw View
===================================== MODERATOR'S COMMENT:
 Topic drift.


===================================== END OF MODERATOR'S COMMENT
ron@sensor.com ("Ron Natalie") wrote in message news:<arMfa.1507$Ca5.490@fe09.atl2.webusenet.com>...

> Well, IBM tried to do away with files.   Of course this ended up being
> non-compliant because ordering info got lost.

False and false.  The incremental C++ compiler that is included in
VisualAge C++ version 4 does not respect declaration order, but the
follow-on version, VisualAge C++ version 5 for AIX does.  Furthermore,
all versions of the incremental C++ compiler use files.

Of course, VisualAge C++ includes a conventional, one-file-at-a-time
batch-mode compiler, too.  The conventional compiler works just like
any other C++ compiler.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: kanze@gabi-soft.de (James Kanze)
Date: Thu, 20 Mar 2003 20:27:26 +0000 (UTC)
Raw View
allan_w@my-dejanews.com (Allan W) wrote in message
news:<7f2735a5.0303181326.42950e26@posting.google.com>...

    [...]
> From a language point of view, the header file is identified with a
> header-name. The standard doesn't say anything about either an
> "extension" or a "filetype." It does say that if the header-name
> includes either the ' or \ character, or either of the character
> sequences /* or //, that the behavior is undefined (but shouldn't this
> be implementation-defined?)

Or if it contains more than one '.'.  Or more than eight characters
before the . or more than 3 after.  At least, these were the rules for
C.  In C++,    16.2/5:

    The mapping between the delimited sequence and the external source
    file name is implementation-defined.  The implementation provides
    unique mappings for sequences consisting of one or more nondigits
    (2.10) followed by a period (.) and a single nondigit.  The
    implementation may ignore the distinctions of alphabetical case.

In C, ~6.10.2/5:

    The implementation shall provide unique mappings for sequences
    consisting of one or more letters or digits (as defined in 5.2.1)
    followed by a period (.) and a single letter.  The first character
    shall be a letter.  The implementation may ignore the distinctions
    of alphabetical case and restrict the mapping to eight significant
    characters before the period.

I'm curious as to why the differences: C allows digits (except for the
first character), C++ doesn't.  C restricts the significant length to 8,
C++ requires (apparently) an infinite significant length (which of
course isn't implementable).

> On the other hand, many C++ compilers come bundled into a language
> processing system, along with an editor, debugger, platform-specific
> libraries, and so on. I'm reasonably sure that there aren't any
> platforms that cannot accept .porno files

I've used several.

> -- after all, the C++ standard has no restriction, and it's important
> to be able to port code to the new platform -- but there are certainly
> quite a few that will make their use less convenient. For example, in
> Microsoft's Visual C++, when you want to create a new C++ Header file
> it automatically gets the name something.h unless you deliberately
> override it. I also suspect that most Lint-like tools would prefer
> that headers end in .h or .hpp.

Funny.  Every project I've ever been on has used .hh.  I've never seen
.hpp outside the Windows world (and I've never seen .H, a frequent Unix
variant, outside of Unix).

> There are at least 3 conventions for filename suffixes (including
> headers) -- pick a row.

>     C code    C headers    C++ code    C++ headers
>     ------    ---------    --------    -----------
>     xxx.c     xxx.h        xxx.cpp     xxx.hpp
>     xxx.c     xxx.h        xxx.cpp     xxx.h
>     xxx.c     xxx.h        xxx.cxx     xxx.hxx

      xxx.c     xxx.h        xxx.C       xxx.h
      xxx.c     xxx.h        xxx.C       xxx.H
      xxx.c     xxx.h        xxx.cc      xxx.hh

The first one is doubtlessly the oldest one; probably the reason why
there are so many is that it doesn't work -- many platforms can't
distinguish between xxx.c and xxx.C, and of course, it is preferable to
be able to distinguish between C headers and purely C++ headers on the
basis of their name.

> I have also heard of (but not worked in) shops where header files
> have .c or .cpp extensions:
>     #include "myclass.cpp" // Yeech!

It's quite frequent to use a different suffix for files containing
inline functions or template implementations, witness Boost's .tcc
(which I'm gradually adopting).  I've also used .mcc and .mhh for
machine dependant code, the xxx.cc includes xxx.mcc, which is found in a
platform dependant directory (specified by a -I option when compiling).
When I still used inline functions, I put them in a .ihh.  And I
occasionally use a .lhh for local headers.

> Some shops prefer to put their inline functions in .CPP files which
> are #included by the appropriate header file...

> But really, it isn't important that you observe The Perfect
> Convention(tm). What IS important, is to be consistent. Pick one way
> to go, and stick with it.

And be ready to change it when you change shops.

--
James Kanze             GABI Software             mailto:kanze@gabi-soft.fr
Conseils en informatique orient   e objet/
                           Beratung in objektorientierter Datenverarbeitung
11 rue de Rambouillet, 78460 Chevreuse, France, T   l. : +33 (0)1 30 23 45 16

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: clarky@hotmail.com ("Clark Kent")
Date: Wed, 19 Mar 2003 19:54:27 +0000 (UTC)
Raw View
> On the Acorn Risc-OS platform the '.' character is the directory
> seperator and the C compiler looked for a file named xxx in subdirectory
> h when processing the #include "xxx.h" directive. It only swapped the
> extension names it knew about (.c .o .h) and not .inc

OK, I correct myself: ... OS specific quirks excluded.

I can think of more: MS-DOS 8.3 filename limitation is a famous one,
ofcourse .porno wouldn't work on MS-DOS either.

But if the file is possible to create in the filesystem then it should be
includable by the c++ compiler on that platform aswell. Some filenames, I
suppose, aren't usable in some other platforms but for the c++ standard that
shouldn't be relevant.. so the .porno extension for the c++ should be a
valid filename extension for the header files. ;-)

The Standard does provide some headers, with filenames, which can't work on
all platforms. In this case it's compilers job to provide mechanism, for
instance filename mapping, which MAKES the Standard headers work. But that's
a topic of it's own, even if parallel with the current one. Thanks.


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: allan_w@my-dejanews.com (Allan W)
Date: Wed, 19 Mar 2003 19:55:42 +0000 (UTC)
Raw View
clarky@hotmail.com ("Clark Kent") wrote
> > have you tried compiling while including a file with
> > a different extension?
> > have you considered that even if it works under one
> > platform it might not on another?
>
> LOL no, you can use .porno extension and it will work, because, it's a
> header file. Text in it will be included, nothing more, nothing less.
> #include is a preprocessor statement, you will notice it from the #
> character. ;-)

You're both right, for some qualified definition of "works."

>From a language point of view, the header file is identified with a
header-name. The standard doesn't say anything about either an
"extension" or a "filetype." It does say that if the header-name
includes either the ' or \ character, or either of the character
sequences /* or //, that the behavior is undefined (but shouldn't this
be implementation-defined?)

On the other hand, many C++ compilers come bundled into a language
processing system, along with an editor, debugger, platform-specific
libraries, and so on. I'm reasonably sure that there aren't any
platforms that cannot accept .porno files -- after all, the C++
standard has no restriction, and it's important to be able to port
code to the new platform --  but there are certainly quite a few
that will make their use less convenient. For example, in Microsoft's
Visual C++, when you want to create a new C++ Header file it
automatically gets the name something.h unless you deliberately
override it. I also suspect that most Lint-like tools would prefer
that headers end in .h or .hpp.

There are at least 3 conventions for filename suffixes (including
headers) -- pick a row.

    C code    C headers    C++ code    C++ headers
    ------    ---------    --------    -----------
    xxx.c     xxx.h        xxx.cpp     xxx.hpp
    xxx.c     xxx.h        xxx.cpp     xxx.h
    xxx.c     xxx.h        xxx.cxx     xxx.hxx

I have also heard of (but not worked in) shops where header files
have .c or .cpp extensions:
    #include "myclass.cpp" // Yeech!
Some shops prefer to put their inline functions in .CPP files
which are #included by the appropriate header file...

But really, it isn't important that you observe The Perfect
Convention(tm). What IS important, is to be consistent. Pick one
way to go, and stick with it.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: musiphil@bawi.org (KIM Seungbeom)
Date: Thu, 20 Mar 2003 05:59:50 +0000 (UTC)
Raw View
allan_w@my-dejanews.com (Allan W) wrote in message news:<7f2735a5.0303181326.42950e26@posting.google.com>...
>
> There are at least 3 conventions for filename suffixes (including
> headers) -- pick a row.
>
>     C code    C headers    C++ code    C++ headers
>     ------    ---------    --------    -----------
>     xxx.c     xxx.h        xxx.cpp     xxx.hpp
>     xxx.c     xxx.h        xxx.cpp     xxx.h
>     xxx.c     xxx.h        xxx.cxx     xxx.hxx

I'll add three:

    C code    C headers    C++ code    C++ headers
    ------    ---------    --------    -----------
    xxx.c     xxx.h        xxx.c++     xxx.h++
    xxx.c     xxx.h        xxx.cc      xxx.hh
    xxx.c     xxx.h        xxx.C       xxx.H

Enough to describe why the Committee wasn't able to choose only one. :-)

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: clarky@hotmail.com ("Clark Kent")
Date: Mon, 17 Mar 2003 21:28:34 +0000 (UTC)
Raw View
> have you tried compiling while including a file with a different
extension?
> have you considered that even if it works under one platform it might not
on
> another?

LOL no, you can use .porno extension and it will work, because, it's a
header file. Text in it will be included, nothing more, nothing less.
#include is a preprocessor statement, you will notice it from the #
character. ;-)


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: dont.spam.mathfox@xs4all.nl (Peter Roozemaal)
Date: Tue, 18 Mar 2003 17:41:54 +0000 (UTC)
Raw View
Clark Kent wrote:
>> have you tried compiling while including a file with a different
>> extension? have you considered that even if it works under one
>> platform it might not on another?
>
> LOL no, you can use .porno extension and it will work, because, it's a
> header file. Text in it will be included, nothing more, nothing less.
> #include is a preprocessor statement, you will notice it from the #
> character. ;-)

On the Acorn Risc-OS platform the '.' character is the directory
seperator and the C compiler looked for a file named xxx in subdirectory
h when processing the #include "xxx.h" directive. It only swapped the
extension names it knew about (.c .o .h) and not .inc

Peter

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: Thomas.Matthews@pb.com (Thomas Matthews)
Date: Tue, 18 Mar 2003 17:42:33 +0000 (UTC)
Raw View
nomail@nomail.com ("Mark J") wrote in message news:<KkQ7a.16721$cB3.84200@nnrp1.uunet.ca>...
> Is there anything in the standard about naming convention for header files?
> What is the accepted naming convention (ie. *.h or *.hpp)?
>
> Thoughts?
>
> Thanks,
>
> Mark
>
> ---
> [ comp.std.c++ is moderated.  To submit articles, try just posting with ]
> [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
> [              --- Please see the FAQ before posting. ---               ]
> [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]

As others stated, with the exception of standard headers, you can name
your header files anything you want with any extension.  Some OSes don't
support extensions.

A general convention is to use ".h" for C language header files (those
header files that can be used by a C compiler or a C++ compiler).  The
".hpp" extension is commonly used to denote header files that are
explicitly for C++ (they contain syntax and constructs that are not
C language compatible, for example, class declarations).

Whatever you choose, be consistent.

-- Thomas Matthews

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: baphomet@forest.com ("Spike")
Date: Fri, 7 Mar 2003 02:36:53 +0000 (UTC)
Raw View
""Mark J"" <nomail@nomail.com> wrote in message
news:KkQ7a.16721$cB3.84200@nnrp1.uunet.ca...
> Is there anything in the standard about naming convention for header
files?
> What is the accepted naming convention (ie. *.h or *.hpp)?
>
> Thoughts?

is there a particular reason you wish to use other extensions?
have you tried compiling while including a file with a different extension?
have you considered that even if it works under one platform it might not on
another?


>
> Thanks,
>
> Mark
>
> ---
> [ comp.std.c++ is moderated.  To submit articles, try just posting with ]
> [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
> [              --- Please see the FAQ before posting. ---               ]
> [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]
>

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: nomail@nomail.com ("Mark J")
Date: Fri, 28 Feb 2003 21:39:26 +0000 (UTC)
Raw View
Is there anything in the standard about naming convention for header files?
What is the accepted naming convention (ie. *.h or *.hpp)?

Thoughts?

Thanks,

Mark

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: dkamen4spam@cslab.ece.ntua.gr (Dimitris Kamenopoulos)
Date: Fri, 28 Feb 2003 23:09:21 +0000 (UTC)
Raw View
Mark J wrote:

> Is there anything in the standard about naming convention for header
> files? What is the accepted naming convention (ie. *.h or *.hpp)?

There is none. You can name them however you want, except for the standard
header names.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: deming.he@worldnet.att.net ("Deming He")
Date: Mon, 3 Mar 2003 03:39:18 +0000 (UTC)
Raw View
"Mark J" <nomail@nomail.com> wrote in message
news:KkQ7a.16721$cB3.84200@nnrp1.uunet.ca...
> Is there anything in the standard about naming convention for header
files?
> What is the accepted naming convention (ie. *.h or *.hpp)?
>
> Thoughts?
>
> Thanks,
>
> Mark
>
> ---
> [ comp.std.c++ is moderated.  To submit articles, try just posting with ]
> [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
> [              --- Please see the FAQ before posting. ---               ]
> [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html

I think ANSI C++ Standard use headers without appending .h.  For example,
<iostream>.  However the existence of <iostream.h> is for the purpose of
backward compatibility.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]