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

Поиск
Список
Период
Сортировка
От Mario Emmenlauer
Тема Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h
Дата
Msg-id b6329de3-4200-946f-610c-b77816b4a858@emmenlauer.de
обсуждение исходный текст
Ответ на 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  (Julien Rouhaud <rjuju123@gmail.com>)
Список pgsql-bugs
Hi Julien,

On 13.01.22 13:23, Julien Rouhaud wrote:
> On Thu, Jan 13, 2022 at 09:11:45AM +0000, PG Bug reporting form wrote:
>> The following bug has been logged on the website:
>>
>> Then I build a wrapper library that uses `postgres.h` in my code. My code is
>> built using the LLVM Clang-Cl compiler frontend version 13.0.0 over
>> Microsoft Visual Studio 19.5. Generally, the Clang-Cl compiler frontend
>> works very well. But since updating PostgreSQL from 13.x to the 14.1
>> release, I get an error:
>> ```
> [...]
>> C:\BDA\bld\XTJyb_7r\0\DatabaseHandler\src\BDAPGResult.cc
>> 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 */
>>        ^
>> C:\Program Files (x86)\Windows
>> Kits\10\include\10.0.19041.0\ucrt\sys/stat.h(87,12): note: previous
>> definition is here
>>     struct stat
>>            ^
>> 1 error generated.
>> ```
> 
> 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?

Actually I do not really mean to include `postgres.h`. But I do want
to identify result types with `Oid vOID = ::PQftype(mResult.get(), vColumn);`
to check the result type. And the types seem to be defined in header
`catalog/pg_type.h` which only worked when `postgres.h` was included before.

I guess I'm off the standard track here. Its not completely mandatory for
me to identify the result types. But it was quite nice to be able to do
so.

Is this actually unsupported? Or am I doing something wrong?

All the best,

   Mario



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

Предыдущее
От: Tomas Barton
Дата:
Сообщение: pg_upgrade --check doesn't check pg_pltemplate modifications
Следующее
От: Mario Emmenlauer
Дата:
Сообщение: Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h