Julien Rouhaud <rjuju123@gmail.com> writes:
> On Thu, Jan 13, 2022 at 09:11:45AM +0000, PG Bug reporting form wrote:
>> In file included from
>> C:\BDA\bld\XTJyb_7r\0\DatabaseHandler\src\BDAPGResult.cc:31:
>> In file included from C:\data\ci-dst\Debug\include\server\postgres.h:46:
>> In file included from C:\data\ci-dst\Debug\include\server/c.h:1362:
>> In file included from C:\data\ci-dst\Debug\include\server/port.h:26:
>> C:\data\ci-dst\Debug\include\server/port/win32_port.h(256,8): error:
>> redefinition of 'stat'
>> struct stat /* This should match
>> struct __stat64 */
> Note that postgres.h is intended for backend-side code, and I'm assuming that
> your wrapper library is client code? Have you tried using postgres_fe.h
> instead?
Generally speaking, client code shouldn't include either of those,
but just libpq-fe.h. Both postgres.h and postgres_fe.h are fairly
invasive in terms of setting up a programming environment that
matches our conventions for backend or frontend code respectively.
If you don't want to drink *all* of that Kool-Aid (which you likely
do not, if you are writing C++), you don't want those headers.
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.
regards, tom lane