[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] namespace clean shared libraries

Daniel P. Berrange wrote:
> If its better to just do it in libvirt config.h, then we
> can do that too

Yes, doing '#define foo libvirt_foo' in config.h is the preferred way
of achieving a namespace clean shared library.

There are two ways to generate these #defines:

1) You collect manually, on various systems, the set of symbols that you
   don't want to clash with symbols from other shared libraries. You need
   to do this on various systems, because gnulib may define functions
   'rpl_fflush' or 'dprintf' on some systems and not on others.

2) You collect, from a set of header files, the set of symbols that you
   want to have exported, and process all other symbols with
     '#define foo libvirt_foo'

   This approach is more robust, but requires to compile all *.o files
   twice: Once with the initial settings (no #define), and once for real.

   This approach is implemented in libunistring. Look at the config.h rule
   in this Makefile.am [1]. There are two auxiliary scripts: 'declared.sh' [2]
   extracts the symbols from a .h file (assuming a particular coding style).
   'exported.sh' [3] extracts te symbols of a .o file.


[1] http://git.savannah.gnu.org/gitweb/?p=libunistring.git;a=blob;f=lib/Makefile.am
[2] http://git.savannah.gnu.org/gitweb/?p=libunistring.git;a=blob;f=lib/declared.sh
[3] http://git.savannah.gnu.org/gitweb/?p=libunistring.git;a=blob;f=lib/exported.sh.in

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]