autoconf
[Top][All Lists]
Advanced

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

Re: How to avoid warning: "PACKAGE_NAME" redefined


From: Stepan Kasal
Subject: Re: How to avoid warning: "PACKAGE_NAME" redefined
Date: Fri, 9 Mar 2007 21:46:32 +0100
User-agent: Mutt/1.4.2.1i

Hello Ralf,

On Fri, Mar 09, 2007 at 10:51:18AM +0100, Ralf Wildenhues wrote:
> If they need an installable file that contains information generated by
> configure, they could use a second config header with a manually written
> template that contains only the minimal set of macros to be defined (and
> those should all be package-specific, e.g., have a prefix like ACE_ or
> so).
> 
> Example:
>   AC_CONFIG_HEADERS(config.h ace_config.h)
> 
> put this in ace_config.h.in:
> 
>   /* clients of the ACE library need to know whether this library was
>      compiled with features FOO and BAR */
>   #undef ACE_FEATURE_FOO
>   #undef ACE_FEATURE_BAR

I agree with this, but there is a trap, so let me go one step
further:

It is probable that the installable config header will be included by
some other installable headers, say ace-beetles.h

And it is usual that this public header is also used within the
project itself, so the corresponding implementation file, say
ace-1.2.3/beetles.c, includes ace-beetles.h.  It also includes
confog.h, of course.

This implies that config.h and ace_config.h are sometimes used
together.  But since ACE_FEATURE_FOO et al. are sniffed out by
autoheader, they get into config.h, too.  Thus you get warnings from
the compiler that ACE_FEATURE_FOO is being defined twice.

I can see two ways to fix this:

1) one can fix ace-beetles.h and all similar files, so that they do
not include ace_config.h when used within the ace pacakge.
Disadvantage: the #ifdef's in the public headers might anoy users of 
ace-*.h.

2) Supposing that ace_config.h is guarded by symbol ACE_CONFIG_H,
define that symbol in config.h, so that ace_config.h is then ignored.
(config.h should be the first include in every *.c file, right?)
The disadvantage is that the implementation might look a bit tricky.
Here is how I did it in goffice/configure.ac:
-----8<-----
dnl This one is created by autoheader, ...
AC_CONFIG_HEADERS(goffice/goffice-config.h)
dnl ... and this one is a small subset, maintained manually,
dnl which will be installed.
AC_CONFIG_HEADERS(goffice/goffice-features.h)
dnl
dnl Make sure these two won't clash.  Put the following to goffice-config.h:
AH_BOTTOM([/* Don't include goffice-features.h, it's a subset of 
goffice-config.h. */
#define GOFFICE_FEATURES_H])
-----8<-----

HTH,
        Stepan Kasal




reply via email to

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