more comfortable approach for exporting dbus functions on windows

Ralf Habacker ralf.habacker at freenet.de
Thu Mar 4 13:33:55 PST 2010


Hi,

in current dbus code exporting symbols from shared libraries on windows 
requires to add the related symbol name in a specific definition file. 
The drawback in using this def files is that an additional step for any 
symbol to export is required and forgotten symbols results sometime in 
hard to find linker errors.

A more comfortable approach is available by using export declarations, 
which are used already in many cross platform projects like Qt and KDE. 
An example how to export a function with this style is shown below:

DBUS_EXPORT
  char* dbus_address_unescape_value (const char *value,
                                                            DBusError  
*error);


On windows the macro DBUS_EXPORT contains the required compiler 
directive to export/import symbols, on non windows os this macro is a noop.

+#if defined(DBUS_WIN)
+#  if defined(dbus_1_EXPORTS)
+#  define DBUS_EXPORT __declspec(dllexport)
+#  else
+#  define DBUS_EXPORT __declspec(dllimport)
+#  endif
+#else
+#define DBUS_EXPORT
+#endif

When building a related shared library the build system sets the 
dbus_1_EXPORTS macro, which selects exporting symbols.


The appended patch adds such support for the public dbus api functions. 
The internal symbols could be adressed in further patches.

BTW: The change to cmake/Doxyfile.cmake supress printing of DBUS_EXPORT 
in the function prototyp.

Please review.

Regards
Ralf


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dbus-export-1.patch
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20100304/5a1de905/attachment.txt>


More information about the dbus mailing list