[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: MDB library naming conflict

Quanah Gibson-Mount writes:
[About name clashes with MDB Tools]
> The only place I can think this could cause an issue would be Debian (and 
> then Ubuntu).  They load all library symbols into a shared address space 
> used by every user, including root.  This has caused me endless nightmare 
> in the past with conflicting symbols between my own LDAP libraries and the 
> debian system libraries when thinks like nss_ldap were in use (loading the 
> system libraries).

mdb_open and mdb_close are the name clashes I see without asking the
compiler (I'd need to install glib).  We could rename those to
mdb_dbi_<open/close>.  Perhaps combined with the compat macros below:

My reasons for preferring a full rename had little to with MDB tools.
If you'd have done that if not for compat issues: A transition isn't
hard, merely ugly.  Something like this at the *beginning* of lmdb.h -
or in lmdb_compat.h, which lmdb.h includes #if (LMDB_COMPAT_2012):

#if (LMDB_COMPAT_2012) /* "2012" to distinguish from future compat macros */
/* First, symbols needing only source-level compat */
# ...
/* Next, binary compat. External names, types+enums for debuggers. */
# if (LMDB_COMPAT_2012) > 0     /* Old source file vs. new liblmdb library */
#  define mdb_open lmdb_open /* Not mdb_open(...). "&mdb_open" would fail. */
#  ...
# else /* (LMDB_COMPAT_2012) < 0:  New source file vs. old libmdb library */
#  define lmdb_open mdb_open /* turns later lmdb_open() decl into mdb_open */
#  ...
# endif
#endif /* LMDB_COMPAT_2012 */

/* Then the "real" lmdb.h */
#define MDB_NOSUBDIR	  0x4000
int lmdb_open(/*...*/);

For that matter, an optionally installed mdb.h could do

#ifndef LMDB_COMPAT_2012
# define LMDB_COMPAT_2012 1
#include "lmdb.h"

I'm not going to be terribly disappointed if this hack is turned down:-)