Thread: Why PGDLLIMPORT is needed

Why PGDLLIMPORT is needed

From
高健
Date:
On /src/include/storage/proc.h:

I saw the following line:

extern PGDLLIMPORT PGPROC *MyProc;

I want to know why PGDLLIMPORT is used here?

Does it mean: exten PGPROC *MyProc;  right?

Re: Why PGDLLIMPORT is needed

From
Craig Ringer
Date:
On 10/29/2012 02:05 PM, 高健 wrote:
> On /src/include/storage/proc.h:
>
> I saw the following line:
>
> extern PGDLLIMPORT PGPROC *MyProc;
>
> I want to know why PGDLLIMPORT is used here?
>
> Does it mean: exten PGPROC *MyProc;  right?

What platform are you working on?

On Windows it's required to allow the static linker to generate the
correct symbol tables and the runtime/dynamic linker to correctly link
binaries. See:

http://support.microsoft.com/kb/132044
http://msdn.microsoft.com/en-us/library/8fskxacy(v=vs.80).aspx
http://msdn.microsoft.com/en-us/library/a90k134d(v=vs.80).aspx

For other platforms the same macros can be used for symbol visibility
filtering, but are usually set to evaluate to nothing so they have no
effect.

"extern" is always implicit for a prototype in a header, so while that
declaration does mean "extern PGPROC *MyPRoc;" that's nothing to do with
the PGDLLIMPORT macro.

--
Craig Ringer


Re: Why PGDLLIMPORT is needed

From
"Xiong He"
Date:
You can check the macro definition there:

#ifdef BUILDING_DLL
#define PGDLLIMPORT __declspec (dllexport)
#else                            /* not BUILDING_DLL */
#define PGDLLIMPORT __declspec (dllimport)
#endif

#ifdef _MSC_VER
#define PGDLLEXPORT __declspec (dllexport)
#else
#define PGDLLEXPORT
#endif

It's only useful on Windows platform for the dll building(import, export) the API entries.


------------------
Thanks&Regards,
Xiong He

 


------------------ Original ------------------
From:  "高健"<luckyjackgao@gmail.com>;
Date:  Mon, Oct 29, 2012 02:05 PM
To:  "pgsql-general"<pgsql-general@postgresql.org>;
Subject:  [GENERAL] Why PGDLLIMPORT is needed

On /src/include/storage/proc.h:

I saw the following line:

extern PGDLLIMPORT PGPROC *MyProc;

I want to know why PGDLLIMPORT is used here?

Does it mean: exten PGPROC *MyProc;  right?

Re: Why PGDLLIMPORT is needed

From
Bruce Momjian
Date:
On Mon, Oct 29, 2012 at 04:41:05PM +0800, Craig Ringer wrote:
> On 10/29/2012 02:05 PM, 高健 wrote:
> > On /src/include/storage/proc.h:
> >
> > I saw the following line:
> >
> > extern PGDLLIMPORT PGPROC *MyProc;
> >
> > I want to know why PGDLLIMPORT is used here?
> >
> > Does it mean: exten PGPROC *MyProc;  right?
>
> What platform are you working on?
>
> On Windows it's required to allow the static linker to generate the
> correct symbol tables and the runtime/dynamic linker to correctly link
> binaries. See:
>
> http://support.microsoft.com/kb/132044
> http://msdn.microsoft.com/en-us/library/8fskxacy(v=vs.80).aspx
> http://msdn.microsoft.com/en-us/library/a90k134d(v=vs.80).aspx
>
> For other platforms the same macros can be used for symbol visibility
> filtering, but are usually set to evaluate to nothing so they have no
> effect.

Thanks, those URLs are helpful, and I added them as C comments to
win32.h.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +