Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h - Mailing list pgsql-bugs

From Mario Emmenlauer
Subject Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h
Date
Msg-id 58a26524-401b-c0d1-cd4a-293fa09c4915@emmenlauer.de
Whole thread Raw
In response to Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On 13.01.22 16:28, Tom Lane wrote:
> In particular, what I gather from the above is that postgres.h is
> probably not the first #include in BDAPGResult.cc.  There are some
> portability tricks we play that are dependent on not having read any
> system header files before the inclusion of postgres[_fe].h, and
> what this failure looks like to me is that you've broken one of
> those tricks.  If you do insist on including one of those headers,
> place it first.

Yes, `postgres.h` not the first include in the file. Actually I can
not include it before `locale` on Linux, otherwise I get the following
error:

In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/locale:41:
In file included from
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/locale_facets_nonio.h:2010:
In file included from
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10/bits/messages_members.h:36:
/usr/include/libintl.h:61:14: error: expected ')'

The header `locale` is a dependency of my string handler, that in turn
includes quite a lot of other headers.

For PostgreSQL 13.x and earlier I could include `postgres.h` last, and
it worked on all platforms.

I can try and isolate my PostgreSQL calls and wrap them in some more
"pure" code, to avoid other includes. Or is there anything else I can
try?

All the best,

    Mario Emmenlauer



pgsql-bugs by date:

Previous
From: Mario Emmenlauer
Date:
Subject: Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h
Next
From: Julien Rouhaud
Date:
Subject: Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h