bug-autoconf
[Top][All Lists]
Advanced

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

Re: Multiple definition of VERSION, PACKAGE and so on


From: Tim Van Holder
Subject: Re: Multiple definition of VERSION, PACKAGE and so on
Date: Wed, 24 Mar 2004 11:34:28 +0100
User-agent: Mozilla Thunderbird 0.5 (Windows/20040207)

Patrick Guio wrote:

On Tue, 23 Mar 2004, Guido Draheim wrote:

As said before - it is TOTAL ERROR to include config.h (here: pack1-config.h)
into header files made publically available to outside projects (here: pack2).

I would definitely like to hear how do you handle the following solution
if you mean this is TOTAL ERROR to include config.h into header files
that are made publically available to outside projects.
As far as now I have a pack1-defs.h header file containing definitions like:

#if defined(HAVE_CONFIG_H)
#include <pack1-config.h>
#endif

#if defined(FLOAT_FIELD)
typedef float pack1Real;
#elif defined(DOUBLE_FIELD)
typedef double pack1Real;
#else
#error macro FLOAT_FIELD or DOUBLE_FIELD must be defined
#endif

typedef blitz::Array<pack1Real,1> Array1dr;
typedef blitz::Array<pack1Real,2> Array2dr;
typedef blitz::Array<pack3Real,3> Array3dr;

typedef blitz::Array<pack1Real,DIM> Field;

For simple cases like the above, one way would be to do something
like this:

[configure.ac]
...
if ...; then
  my_real_type_var=double
else
  my_real_type_var=float
fi
...
AC_SUBST([BLITZ_REAL_TYPE], $my_real_type_var)
...
AC_CONFIG_FILES([pack1-defs.h:pack1-defs-h.in])
...

[pack1-defs-h.in]
...
typedef @BLITZ_REAL_TYPE@ pack1Real;
...


In your code, the #error suggests that it would be OK for the client
code to provide FLOAT_FIELD or DOUBLE_FIELD, when in fact that decision
has already been made during pack1's configuration.  What's more, you
leave the inclusion of pack1's config.h up to the user (who has to
define HAVE_CONFIG_H for you).
Typically, every installed file that in some way depends on
configuration-time variables will be an autoconf output file.
AX_PREFIX_CONFIG_HEADER is a way around this for cases where there are
so many relevant #defines that the approach shown becomes impractical.






reply via email to

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