# HG changeset patch # User John W. Eaton # Date 1455123437 18000 # Node ID 7af5ca01ecaccbe19a8103a06bef62f8efddebee # Parent ffc9806bb30048658ced9820f3d76c3753c6710a allow octave-config.h to be included unconditionally * oct-conf-post.in.h (OCTAVE_AUTOCONFIG_H_INCLUDED): Rename from OCTAVE_CONFIG_H_INCLUDED. * mk-octave-config-h.sh: Protect contents of generated file with OCTAVE_AUTOCONFIG_H_INCLUDED. * oct-refcount.h: Simply include octave-config.h instead of checking OCTAVE_CONFIG_H_INCLUDED. diff -r ffc9806bb300 -r 7af5ca01ecac build-aux/mk-octave-config-h.sh --- a/build-aux/mk-octave-config-h.sh Wed Feb 10 11:46:14 2016 -0500 +++ b/build-aux/mk-octave-config-h.sh Wed Feb 10 11:57:17 2016 -0500 @@ -18,6 +18,10 @@ # along with Octave; see the file COPYING. If not, see # . +# Generate a header file that provides the public symbols from Octave's +# autoconf-generated config.h file. See the notes at the top of the +# generated octave-config.h file for more details. + if [ $# -ne 1 ]; then echo "usage: mk-octave-config-h.sh CONFIG-FILE" 1>&2 exit 1 @@ -49,9 +53,45 @@ */ +/* + +All Octave source files should begin with + + #if defined (HAVE_CONFIG_H) + # include + #endif + +All public Octave header files should have the form + + #if ! defined (INCLUSION_GUARD_SYMBOL) + #define INCLUSION_GUARD_SYMBOL 1 + + #include "octave-config.h" + + // Contents of header file. + + #endif + +In Octave source files, INCLUSION_GUARD_SYMBOL should have the form + + octave_NAME_h + +with NAME formed from the header file name with '-' replaced by '_'. + +It is safe to include octave-config.h unconditionally since it will +expand to an empty file if it is included after Octave's +autoconf-generated config.h file. + +Users of Octave's libraries should not need to include octave-config.h +since all of Octave's header files already include it. + +*/ + #if ! defined (octave_octave_config_h) #define octave_octave_config_h 1 +#if ! defined (OCTAVE_AUTOCONFIG_H_INCLUDED) + #include #if defined (__GNUC__) @@ -175,4 +215,6 @@ cat << EOF #endif + +#endif EOF diff -r ffc9806bb300 -r 7af5ca01ecac liboctave/util/oct-refcount.h --- a/liboctave/util/oct-refcount.h Wed Feb 10 11:46:14 2016 -0500 +++ b/liboctave/util/oct-refcount.h Wed Feb 10 11:57:17 2016 -0500 @@ -23,9 +23,7 @@ #if ! defined (octave_oct_refcount_h) #define octave_oct_refcount_h 1 -#ifndef OCTAVE_CONFIG_INCLUDED -# error "The file must be included before oct-refcount.h." -#endif +#include "octave-config.h" #if defined (OCTAVE_ENABLE_ATOMIC_REFCOUNT) && (defined (_MSC_VER) || defined (__GNUC__)) # if defined (_MSC_VER) diff -r ffc9806bb300 -r 7af5ca01ecac oct-conf-post.in.h --- a/oct-conf-post.in.h Wed Feb 10 11:46:14 2016 -0500 +++ b/oct-conf-post.in.h Wed Feb 10 11:57:17 2016 -0500 @@ -185,5 +185,9 @@ typedef OCTAVE_IDX_TYPE octave_idx_type; -/* Tag indicating Octave config.h has been included */ -#define OCTAVE_CONFIG_INCLUDED 1 +/* Tag indicating Octave's autoconf-generated config.h has been + included. This symbol is provided because autoconf-generated + config.h files do not define a multiple-inclusion guard. See also + the notes at the top of the generated octave-config.h file. */ + +#define OCTAVE_AUTOCONFIG_H_INCLUDED 1