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: Mike Miller
Subject: Re: fix for bug #47381, how to order #includes
Date: Sat, 26 Mar 2016 09:37:16 -0700
User-agent: Mutt/1.5.24 (2015-08-30)

On Sat, Mar 26, 2016 at 11:43:05 -0400, John W. Eaton wrote:
> 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.

The specific case here is when a set of header files are included
conditionally, and there is also conditional code in the source file.

In gl2ps-print.cc, most of the header files are #included only if
HAVE_GL2PS_H is defined, because most of the code in that file is only
compiled under the same condition. However, the corresponding header
file gl2ps-print.h always needs to be #included.

Should we always include header files even if they are not needed when
certain functions are skipped?

If we consider it important to speed up the compilation by not
#include-ing files that are not needed in certain cases, should we keep
this code as it is, or should we separate the headers from the code and
use a pattern like this:

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#ifdef HAVE_GL2PS_H
// include conditionally needed system headers
// include conditionally needed Octave headers
#endif

// include unconditionally needed Octave headers
// include this module's header file

#ifdef HAVE_GL2PS_H
// condtional code here
#endif

// unconditional code here

-- 
mike



reply via email to

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