Re: GUC variables invisible to contrib/ modules

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Mark Cave-Ayland <m(dot)cave-ayland(at)webbased(dot)co(dot)uk>
Cc: pgsql-hackers-win32(at)postgresql(dot)org
Subject: Re: GUC variables invisible to contrib/ modules
Date: 2004-08-11 16:15:11
Message-ID: 411A460F.1020500@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers-win32 pgsql-patches

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

In response to

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Tom Haddon 2004-08-11 19:09:50 Import from Linux to Windows
Previous Message Mark Cave-Ayland 2004-08-11 13:02:28 GUC variables invisible to contrib/ modules under Win32

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-08-11 16:31:09 Re: pg_dump 'die_on_errors'
Previous Message Philip Warner 2004-08-11 16:02:59 pg_dump 'die_on_errors'