Re: GUC variables invisible to contrib/ modules - Mailing list pgsql-hackers-win32

From Andreas Pflug
Subject Re: GUC variables invisible to contrib/ modules
Date
Msg-id 411A460F.1020500@pse-consulting.de
Whole thread Raw
In response to GUC variables invisible to contrib/ modules under Win32  ("Mark Cave-Ayland" <m.cave-ayland@webbased.co.uk>)
List pgsql-hackers-win32
Mark Cave-Ayland wrote:
> Under Linux, PostGIS compiles and links fine without any trouble.
> However, when compiling under Win32 we get the following message:
>
> Info: resolving _default_statistics_target by linking to
> __imp__default_statistics_target (auto-import)
> fu000024.o(.idata$3+0xc): undefined reference to `libpostgres_a_iname'
> nmth000023.o(.idata$4+0x0): undefined reference to
> `_nm__default_statistics_target'
> c:\mingw\bin\dllwrap.exe: c:\mingw\bin\gcc exited with status 1
>
>
> The current "fix" to enable this to work correctly is to change the
> relevant line in /src/include/commands/vacuum.h from "extern int
> default_statistics_target;" to "extern DLLIMPORT int
> default_statistics_target;". However, I'm not convinced this is the
> correct fix given that other contrib modules may require access to other
> GUC variables.


It would be fine if all non-static variables would be defined
extern DLLIMPORT, but since non-backend modules don't regularly access
those variables most won't have that keyword. Additionally, this is yet
another M$ issue, non-existent anywhere else.

A work around is to redefine the prototype when you use it, i.e. after
all pgsql includes you define
extern DLLIMPORT int default_statistics_target;
in your sources. Apparently, the compiler will respect the latest
definition and resolve the reference cleanly.

Regards,
Andreas



pgsql-hackers-win32 by date:

Previous
From: "Mark Cave-Ayland"
Date:
Subject: GUC variables invisible to contrib/ modules under Win32
Next
From: "Tom Haddon"
Date:
Subject: Import from Linux to Windows