[sane-devel] [RFC] On libsane symbols visibility
hostcc at gmail.com
Tue May 8 14:46:04 UTC 2007
Doing native Win32 porting and new backend adding I ran into the
question about libsane symbols visibility. That's what 'make libcheck'
Current libsane model (or better to say, programming conventions)
don't allow to export unnecessary symbols from libsane libraries.
That's wise because of possible namespace pollution on a process which
loads such a library. But that's also doesn't allow to traditionally
develop a backend which consists of several object files because
internal symbols which are necessary to be visible from one such file
(for example, a backend could be split into several parts according to
their meaning, which is rather typical even for existing backends)
will also be exported on resulting libsane library.
The problem is worse on other platforms, where some POSIX functions
are not available and implemented by lib/*.c - their symbols will be
exported as well.
My suggestion is to mark the functions which are part of SANE API as
exportable (__attribute__ ((visibility("default"))) symbol attribute
and its companion, -fvisibility=hidden). It will give us the necessary
result - only explicitly marked symbols will be visible. In ideal
case, 'make libcheck' wouldn't be necessary anymore. The above
mentioned attribute and command line switch is a GCC extension.
More information about the sane-devel