pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Julien Rouhaud <rjuju123@gmail.com>
Cc: mario@emmenlauer.de
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h
Date: Thu, 13 Jan 2022 10:28:16 -0500
Message-ID: <3152885.1642087696@sss.pgh.pa.us> (raw)
In-Reply-To: <20220113122310.ay24ciikcu257nkp@jrouhaud>
References: <17365-c58cbf9d0c29586a@postgresql.org>
	<20220113122310.ay24ciikcu257nkp@jrouhaud>

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





view thread (7+ messages)  latest in thread

Message-ID: <3152885.1642087696@sss.pgh.pa.us>
Permalink:  ../3152885.1642087696@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3152885.1642087696@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, rjuju123@gmail.com, mario@emmenlauer.de, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h
  In-Reply-To: <3152885.1642087696@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox