> On Thu, Oct 09, 2008 at 03:17:40PM -0700, Alan Irwin wrote:
> It is. Setting xxxUSINGDLL for the drivers ensures that all the
> symbols from the core library defined in plplot.h etc are imported into
> the driver. This is ok. However, there are some symbols in the driver
> files which are exported to the core library (mostly the dispatch_init
> function and DEVICE INFO structure. I think these would need
> xxxMAKINGDLL defined. Or am I missing something here?
>

If I understand the issue of IMPORT/EXPORT correctly, then:
- EXPORT is always necessary to make the function visible
  outside the DLL.
- IMPORT is used to tell the linker that the function is coming
  from another library, so that it can prepare for a faster call
  (otherwise one or two extra instructions are required).
- IMPORT is _not_ needed for a function when that function is
  called by another function in the same library - it makes
  the call less efficient even. So, IMPORT should go into
  the header files exclusively.

The situation Andrew describes with the dynamic drivers can be
schematised as follows:

We have functions A and B in the core library and function C
in the driver library. A uses C and C uses B.

When making the core library:

EXPORT: A (if it is part of the public interface or used by the bindings)
EXPORT: B (because it is needed - at least - by the driver)
IMPORT: C (as it is used by A)

When making the driver library:

EXPORT: C (part of the "public" interface of the driver)
IMPORT: B (C needs to call it)

If this schema is complete and I read the sources (and especially
the header files) correctly, then we do have an issue with the
IMPORT part:

When compiling the driver library:

#include "plplotP.h"  <-- PLDLLIMPEXP is defined and so are the
                          import/export attributes for A and B
                          from the core library. So, as we are
                          compiling a DLL: the attribute is EXPORT
#include "drivers.h"  <-- defines the atttribute for C to be
                          PLDLLIMPEXP and therefore EXPORT

It would seem necessary to have a setup in the driver library as:

#define USINGDLL
#include "plplotP.h"  <-- IMPORT: A, B (only B needed)
#undef USINGDLL
#define MAKINGDLL
#include "pldll.h"
#include "drivers.h"  <-- EXPORT: C

and in the core:

#define USINGDLL
#include "pldll.h"
#include "drivers.h"  <-- IMPORT: C
#define MAKINGDLL
#include "plplotP.h"  <-- EXPORT: A, B

Please examine this carefully, because it is fairly complicated
and the IMPORT attribute has only a subtle effect (that is: it
affects the performance, getting it wrong will not cause a
compile or link error!).

Regards,

Arjen
>
>


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to