Thread: Re: GUC variables invisible to contrib/ modules

Re: GUC variables invisible to contrib/ modules

From
"Mark Cave-Ayland"
Date:
> -----Original Message-----
> From: pgsql-hackers-win32-owner@postgresql.org
> [mailto:pgsql-hackers-win32-owner@postgresql.org] On Behalf
> Of Andreas Pflug
> Sent: 11 August 2004 17:15
> To: Mark Cave-Ayland
> Cc: pgsql-hackers-win32@postgresql.org
> Subject: Re: [pgsql-hackers-win32] GUC variables invisible to
> contrib/ modules
>
>
> 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


Hi Andreas,

Thanks for the suggestion - it worked exactly as you suspected, and the
compile completed without any further problems. Since no-one else has
commented on the correct method to access GUC variables (particularly
custom variables), I'll go for this approach at the moment.


Many thanks,

Mark.

---

Mark Cave-Ayland
Webbased Ltd.
Tamar Science Park
Derriford
Plymouth
PL6 8BX
England

Tel: +44 (0)1752 764445
Fax: +44 (0)1752 764446


This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender. You
should not copy it or use it for any purpose nor disclose or distribute
its contents to any other person.