Mercurial > jwe > octave
changeset 21240:7af5ca01ecac
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.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2016 11:57:17 -0500 |
parents | ffc9806bb300 |
children | bae38398f5f1 |
files | build-aux/mk-octave-config-h.sh liboctave/util/oct-refcount.h oct-conf-post.in.h |
diffstat | 3 files changed, 49 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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 # <http://www.gnu.org/licenses/>. +# 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 <config.h> + #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 <stdint.h> #if defined (__GNUC__) @@ -175,4 +215,6 @@ cat << EOF #endif + +#endif EOF
--- 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 <octave/config.h> 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)
--- 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