more comfortable approach for exporting dbus functions on windows

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


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:

  char* dbus_address_unescape_value (const char *value,

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
+#define DBUS_EXPORT

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.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dbus-export-1.patch
URL: <>

More information about the dbus mailing list