Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #7486 > unrolled thread

Header file naming convention

Started bySteve Keller <keller@no.invalid>
First post2011-07-05 21:03 +0200
Last post2011-07-06 17:30 +0800
Articles 11 — 8 participants

Back to article view | Back to comp.lang.c++


Contents

  Header file naming convention Steve Keller <keller@no.invalid> - 2011-07-05 21:03 +0200
    Re: Header file naming convention Juha Nieminen <nospam@thanks.invalid> - 2011-07-05 19:10 +0000
    Re: Header file naming convention "Bo Persson" <bop@gmb.dk> - 2011-07-05 21:26 +0200
    Re: Header file naming convention Gert-Jan de Vos <gert-jan.de.vos@onsneteindhoven.nl> - 2011-07-05 12:44 -0700
      Re: Header file naming convention Asger-P <junk@asger-p.dk> - 2011-07-06 00:17 +0200
        Re: Header file naming convention Qi <no@no.no> - 2011-07-06 17:34 +0800
    Re: Header file naming convention Qi <no@no.no> - 2011-07-06 10:04 +0800
      Re: Header file naming convention Garrett Hartshaw <ghartshaw@gmail.com> - 2011-07-06 02:12 -0400
      Re: Header file naming convention Steve Keller <keller@no.invalid> - 2011-07-06 10:36 +0200
        Re: Header file naming convention Miles Bader <miles@gnu.org> - 2011-07-06 18:22 +0900
        Re: Header file naming convention Qi <no@no.no> - 2011-07-06 17:30 +0800

#7486 — Header file naming convention

FromSteve Keller <keller@no.invalid>
Date2011-07-05 21:03 +0200
SubjectHeader file naming convention
Message-ID<iuvnbq$1isg$1@adenine.netfront.net>
What do you name your header files?  .h, .hh, .hpp or something else.
I currently use .h but I tned to switch to .hh.

--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

[toc] | [next] | [standalone]


#7487

FromJuha Nieminen <nospam@thanks.invalid>
Date2011-07-05 19:10 +0000
Message-ID<4e1361b6$0$2819$7b1e8fa0@news.nbl.fi>
In reply to#7486
Steve Keller <keller@no.invalid> wrote:
> What do you name your header files?  .h, .hh, .hpp or something else.
> I currently use .h but I tned to switch to .hh.

  I don't like the extension .h for C++ headers because it's confusing.
The name implies it's a C header file, while it isn't.

[toc] | [prev] | [next] | [standalone]


#7489

From"Bo Persson" <bop@gmb.dk>
Date2011-07-05 21:26 +0200
Message-ID<97h6qbFqmeU1@mid.individual.net>
In reply to#7486
Steve Keller wrote:
> What do you name your header files?  .h, .hh, .hpp or something
> else.
> I currently use .h but I tned to switch to .hh.
>

It doesn't matter, a header is a header, and .h can mean header. What 
does hh mean?


Bo Persson

[toc] | [prev] | [next] | [standalone]


#7491

FromGert-Jan de Vos <gert-jan.de.vos@onsneteindhoven.nl>
Date2011-07-05 12:44 -0700
Message-ID<7f032ffd-d164-477e-b57a-f1350325cbff@29g2000yqb.googlegroups.com>
In reply to#7486
On Jul 5, 9:03 pm, Steve Keller <kel...@no.invalid> wrote:
> What do you name your header files?  .h, .hh, .hpp or something else.
> I currently use .h but I tned to switch to .hh.

.h and .hpp seem to be most common. I started with .h headers because
my IDE (MSVC6) at the time didn't support the .hpp extension. I stay
with that choice for consistency.

Boost usually does the right thing in the C++ world, which suggests
.hpp

Gert-Jan

[toc] | [prev] | [next] | [standalone]


#7500

FromAsger-P <junk@asger-p.dk>
Date2011-07-06 00:17 +0200
Message-ID<op.vx52upif2juju3@ajwin7>
In reply to#7491
Hi Gert-Jan de Vos

On the: 05. of juli-2011 At: 21:44 Gert-Jan de Vos wrote:

> On Jul 5, 9:03 pm, Steve Keller <kel...@no.invalid> wrote:
>> What do you name your header files?  .h, .hh, .hpp or something else.
>> I currently use .h but I tned to switch to .hh.
>
> .h and .hpp seem to be most common. I started with .h headers because
> my IDE (MSVC6) at the time didn't support the .hpp extension. I stay
> with that choice for consistency.
>
> Boost usually does the right thing in the C++ world, which suggests
> .hpp

Isn't .hpp a pascal header ? (it is when using Delphi)


Best regards
Asger-P

[toc] | [prev] | [next] | [standalone]


#7520

FromQi <no@no.no>
Date2011-07-06 17:34 +0800
Message-ID<iv1a6m$ls6$2@speranza.aioe.org>
In reply to#7500
On 2011-7-6 6:17, Asger-P wrote:
>
> Isn't .hpp a pascal header ? (it is when using Delphi)

If you are talking about BCB, AFAIR, .hpp is the
C++ header files of VCL framework.
Pascal (Delphi) has no header files.

-- 
WQ

[toc] | [prev] | [next] | [standalone]


#7504

FromQi <no@no.no>
Date2011-07-06 10:04 +0800
Message-ID<iv0fqn$274$1@speranza.aioe.org>
In reply to#7486
On 2011-7-6 3:03, Steve Keller wrote:
> What do you name your header files?  .h, .hh, .hpp or something else.
> I currently use .h but I tned to switch to .hh.

Stay with either .h or .hpp, both are OK and well known by people.
Don't use .hh, who knows it?
We using .cc for source code doesn't mean we use .hh for header files...

-- 
WQ

[toc] | [prev] | [next] | [standalone]


#7510

FromGarrett Hartshaw <ghartshaw@gmail.com>
Date2011-07-06 02:12 -0400
Message-ID<almarsoft.901680786382413076@news.eternal-september.org>
In reply to#7504
On Wed, 06 Jul 2011 10:04:07 +0800, Qi <no@no.no> wrote:
> On 2011-7-6 3:03, Steve Keller wrote:
> > What do you name your header files?  .h, .hh, .hpp or something 
else.
> > I currently use .h but I tned to switch to .hh.


> Stay with either .h or .hpp, both are OK and well known by people.
> Don't use .hh, who knows it?
> We using .cc for source code doesn't mean we use .hh for header 
files...


> -- 
> WQ

I personally like .hh, it fits with .cc.
My opinion is that if you use .cpp for sources, use .hpp and if you 
use .cc, use .hh.
Don't use .h because that is a C header (I don't care if others use 
it, just don't). 

Also, enough people use (or can at least recognize) .hh, and that 
shouldn't be an issue in any case.

[toc] | [prev] | [next] | [standalone]


#7516

FromSteve Keller <keller@no.invalid>
Date2011-07-06 10:36 +0200
Message-ID<iv170q$6o5$1@adenine.netfront.net>
In reply to#7504
For example, emacs knows it.  For some reason I don't like .cpp and
use .cc.  Consequently, I tend to prefer .hh over .hpp.  OTOH, I'd
prefer to not use something very unusual.  Does nobody else use .hh?







--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

[toc] | [prev] | [next] | [standalone]


#7517

FromMiles Bader <miles@gnu.org>
Date2011-07-06 18:22 +0900
Message-ID<buotyazwyox.fsf@dhlpc061.dev.necel.com>
In reply to#7516
Steve Keller <keller@no.invalid> writes:
> For example, emacs knows it.  For some reason I don't like .cpp and
> use .cc.  Consequently, I tend to prefer .hh over .hpp.  OTOH, I'd
> prefer to not use something very unusual.  Does nobody else use .hh?

I've certainly seen code-bases that use .hh (don't recall where offhand).

Just plain .h seems very common with C++ headers though.

[Obviously the compiler doesn't care, but for Emacs, I have a little
hack that chooses c++-mode or c-mode for .h files:

   (add-to-list 'auto-mode-alist '("\\.h$" . c-or-c++-mode))

   (defun c-or-c++-mode ()
     "Choose c-mode or c++-mode, depending on the contents of the file."
     (interactive)
     (if (save-excursion
           (goto-char (point-min))
           (re-search-forward "\\<class\\|virtual\\|//\\|::\\>" nil t))
         (c++-mode)
       (c-mode)))

... not so clever, but it generally does the job.]

-miles

-- 
"I distrust a research person who is always obviously busy on a task."
   --Robert Frosch, VP, GM Research

[toc] | [prev] | [next] | [standalone]


#7519

FromQi <no@no.no>
Date2011-07-06 17:30 +0800
Message-ID<iv19vr$ls6$1@speranza.aioe.org>
In reply to#7516
On 2011-7-6 16:36, Steve Keller wrote:
> For example, emacs knows it.  For some reason I don't like .cpp and
> use .cc.  Consequently, I tend to prefer .hh over .hpp.  OTOH, I'd
> prefer to not use something very unusual.  Does nobody else use .hh?

FYI, I just checked several open source libraries on my machine,

Boost -- hpp
wxWidgets -- h
Qt -- h
Google V8 -- h
Luabind -- hpp
libsigc++ -- h (it uses .cc for source code)
Loki -- h

I think at least .hh is quite less common than .hpp and .h, if
not nobody knows it.


-- 
WQ

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web