Thread: Conflicts with autoconf macroses

Conflicts with autoconf macroses

From
Olleg
Date:
SuSE Linux 8.2 (i586)
PostgreSQL REL7_4_STABLE (cvs), 7.4
compiled with:
gcc (GCC) 3.3 20030226 (prerelease) (SuSE Linux)
flex version 2.5.4
bison (GNU Bison) 1.875
PostgreSQL config.status 7.4
configured by ./configure, generated by GNU Autoconf 2.53,
   with options "'--prefix=/opt/pgsql' '--enable-integer-datetimes'
'--enable-thread-safety' '--disable-largefile' '--with-java'
'--with-pam' '--with-openss' '--with-gnu-ld'"

I develop postgresql module and use autoconf to perform some check and
configure. When I try to compile with PostgreSQL 7.4 I get ugly messages
like:

../config.h:56:1: warning: "PACKAGE_VERSION" redefined
In file included from /opt/pgsql/include/server/c.h:53,
                  from /opt/pgsql/include/server/postgres.h:48,
                  from pgat.h:8,
                  from pgat1.c:3:
/opt/pgsql/include/server/pg_config.h:571:1: warning: this is the
location of the previous definition

It's bug, autoconf headers may not be included in "library headers".

Workaround:

#include <postgres.h>

/* Undefine conflict macroses from pg_config.h included in postgres.h
    and our config.h
*/
#undef PACKAGE_VERSION
#undef PACKAGE_TARNAME
#undef PACKAGE_STRING
#undef PACKAGE_NAME
#undef PACKAGE_BUGREPORT

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif


--
Olleg

Re: Conflicts with autoconf macroses

From
Tom Lane
Date:
Olleg <olleg@jane.telecom.mipt.ru> writes:
> It's bug, autoconf headers may not be included in "library headers".

If you think it's a bug you'd better complain to the autoconf people.
pg_config.h is generated entirely by autoconf tools.

            regards, tom lane

Re: Conflicts with autoconf macroses

From
Peter Eisentraut
Date:
Tom Lane writes:

> Olleg <olleg@jane.telecom.mipt.ru> writes:
> > It's bug, autoconf headers may not be included in "library headers".
>
> If you think it's a bug you'd better complain to the autoconf people.
> pg_config.h is generated entirely by autoconf tools.

Admittedly, you're not supposed to install the generated config.h files,
because of this kind of name conflict.  There is a contributed macro that
automatically prefixes all macro names so they don't conflict.  May be
worth checking out.

--
Peter Eisentraut   peter_e@gmx.net

Re: Conflicts with autoconf macroses

From
Olleg
Date:
Peter Eisentraut wrote:
> Tom Lane writes:
>
>
>>Olleg <olleg@jane.telecom.mipt.ru> writes:
>>
>>>It's bug, autoconf headers may not be included in "library headers".
>>
>>If you think it's a bug you'd better complain to the autoconf people.
>>pg_config.h is generated entirely by autoconf tools.
>
> Admittedly, you're not supposed to install the generated config.h files,

I am working on a server module. I need postgresql.h. pg_config.h is
included in postgresql.h

> because of this kind of name conflict.  There is a contributed macro that
> automatically prefixes all macro names so they don't conflict.  May be
> worth checking out.

??? Please explain.

--
Olleg

Re: Conflicts with autoconf macroses

From
Olleg
Date:
Tom Lane wrote:
> Olleg <olleg@jane.telecom.mipt.ru> writes:
>
>>It's bug, autoconf headers may not be included in "library headers".
>
>
> If you think it's a bug you'd better complain to the autoconf people.
> pg_config.h is generated entirely by autoconf tools.

The most libraries use autoheader, but don't generate such error.
Generation of pg_config.h is ok. The only mistake is include such
autoconf header in headers designed to use with external programs, spi
modules in this case. Autoconf header must be included in source
directly or included in headers for internal use only. And don't be
installed along with other library headers.

Re: Conflicts with autoconf macroses

From
Peter Eisentraut
Date:
Olleg writes:

> > because of this kind of name conflict.  There is a contributed macro that
> > automatically prefixes all macro names so they don't conflict.  May be
> > worth checking out.
>
> ??? Please explain.

http://ac-archive.sourceforge.net/guidod/ax_prefix_config_h.html