octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fix for bug #47381, how to order #includes


From: John W. Eaton
Subject: Re: fix for bug #47381, how to order #includes
Date: Sat, 26 Mar 2016 11:43:05 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0

On 03/25/2016 10:51 PM, Carnë Draug wrote:

Last year I ran iwyu (Includ What You Use)[1] on Octave code which found a
missing includes (and some no longer includes as well).  I ended up not
acting on it for lack of time but if anyone is looking at it now.

I have no objection to cleaning them up. I've wanted to do this at various times, but it's difficult without a tool and I didn't know one existed.

About the order of includes, I have been using the following order (with an
empty line betweeb each of the sections):

   1. This file header (not included if it's a header itself).
   2. C system files.
   3. C++ system files.
   4. Other libraries' .h files.
   5. Rest of project .h files.

The Octave sources generally use the following order:

  config.h

  The C++ wrappers for C headers (cstdlib, cassert, etc.)

  C++ standard library headers (iostream, list, map, etc.)

Other POSIX headers (sys/types.h, unistd.h, etc., no need to use #if defined (HAVE_FOO_H) if existence is guaranteed because of gnulib)

Other library header files (glpk.h, curl.h, etc., should be protected by "#if defined (HAVE_FOO_H)" since they may be missing on the build system)

  Octave's liboctave headers

  Octave's libinterp headers

Each grouping of header files should be alphabetized unless there is some specific reason to not do that. The only case I know of where that is true is in oct-parse.in.yy and there is a comment in the file for that one.

jwe





reply via email to

[Prev in Thread] Current Thread [Next in Thread]