Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h

From: Mario Emmenlauer <mario(at)emmenlauer(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h
Date: 2022-01-16 15:14:19
Message-ID: 58a26524-401b-c0d1-cd4a-293fa09c4915@emmenlauer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Julien Rouhaud 2022-01-16 15:18:35 Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h
Previous Message Mario Emmenlauer 2022-01-16 15:06:45 Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h