Re: problem with msvc linker - cannot build orafce - Mailing list pgsql-hackers

From Craig Ringer
Subject Re: problem with msvc linker - cannot build orafce
Date
Msg-id CAMsr+YG2kBeLcG-1g67KCtKryuuE+5ERoN0rAYAYRNHNWW8LvQ@mail.gmail.com
Whole thread Raw
In response to Re: problem with msvc linker - cannot build orafce  (Craig Ringer <craig@2ndquadrant.com>)
Responses Re: problem with msvc linker - cannot build orafce  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers

I don't think that's necessary, per above. You just have to access the vars via pointer indirection always, so long as *any* Pg version you support has ever lacked dllexport or DEF entry, so you can't dllimport the var.

You could enable direct dllimport if PG_VERSION_NUM shows you're on a new enough version, but you'd need to use conditionally compiled inlines or something to switch between the methods of accessing it, so there's not much point. You just declare

extern int* log_min_messages_p;

... and use that, probably also #define'ing log_min_messages away after including the Pg headers so that you can't reference it accidentally.


Actually, if __declspec(dllexport) or a .DEF entry was added in, say, 9.4.5, you could probably just:

#if PG_VERSION_NUM < 90405
extern int* log_min_messages_p;
#define log_min_messages (*log_min_messages_p)
#endif

after including all PostgreSQL headers. It won't work for inline functions defined in PostgreSQL headers, but should otherwise be OK I think.

(again, untested)

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: custom function for converting human readable sizes to bytes
Next
From: Craig Ringer
Date:
Subject: Re: WIP: About CMake v2