Win32 exports
Kosina, Martin
martin.kosina at intel.com
Tue Apr 25 10:33:43 PDT 2006
> > When using a function from a DLL on Windows, the normal way
>is that the
> > function is declared __declspec(dllimport). The user code
>won't need any
> > special modification to compile and link.
>
> > they need special compiler and/or linker options to let the
> > compiler/linker know that some of the functions are to be imported.
>
>Hmm, I think you are confused. Even without __declspec(dllimport),
>user code that calls such functions don't need any special
>modifications or options.
Tor is right, just tried it and it will link without
_declspec(dllimport) as long as it has the .LIB file. So, it comes down
to aesthetics, mostly:
Options:
A) Go with something like DBUS_API (evaluates to either
dllexport,dllimport on Win32, nothing on Linux/Posix.
Advantages: Theoretically faster call due to the hint. Windoze
programmers are used to it (MS "recommended" way, per MSDN).
Disadvantages: Extra macros in all public headers. Extra #include
"win32-exports.h" or similar, that defines such conditional macro.
B) Generate .DEF file (somehow - would have to look into the details)
and specify options to the linker to generate a .LIB based on it.
Advantages: No additions to public headers. No extra header file.
Disadvantages: Need to re-generate .DEF every time _dbus public
functions change or are added. If this requires any custom
utility/script, it will have to become part of the supplied build. Extra
switches to linker (for library build only). Theoretical minor overhead
on each call.
Vote ?
----
Martin Kosina
Intel Corporation / JF4-356
Hillsboro, Ore. 97124, USA
+1-503-712-8162
More information about the dbus
mailing list