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


Groups > comp.lang.c++ > #7517

Re: Header file naming convention

From Miles Bader <miles@gnu.org>
Newsgroups comp.lang.c++
Subject Re: Header file naming convention
Date 2011-07-06 18:22 +0900
Organization NEC Electronics
Message-ID <buotyazwyox.fsf@dhlpc061.dev.necel.com> (permalink)
References <iv0fqn$274$1@speranza.aioe.org> <iv170q$6o5$1@adenine.netfront.net>

Show all headers | View raw


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

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web