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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h
Дата
Msg-id 3152885.1642087696@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h  (Julien Rouhaud <rjuju123@gmail.com>)
Ответы Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h  (Mario Emmenlauer <mario@emmenlauer.de>)
Список pgsql-bugs
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



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: BUG #17362: Error "could not find block containing chunk" when using index with icu collation on CentOS 7
Следующее
От: Andres Freund
Дата:
Сообщение: Re: BUG #17255: Server crashes in index_delete_sort_cmp() due to race condition with vacuum