bug-gnulib
[Top][All Lists]
Advanced

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

[Bug-gnulib] Symbol collision


From: Simon Josefsson
Subject: [Bug-gnulib] Symbol collision
Date: Thu, 10 Jul 2003 11:20:49 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

This appear to be a pretty basic problem, so I'm probably missing
something fundamental; help appreciated.

I have added some gnulib functions to one library, libgss.so.

I'm now working on adding some gnulib functions to another library,
libgsasl.so.

It occured to me that if some of these functions happen to be included
in both libraries, e.g. strdup, won't linking an application to both
libraries break?  The same symbol would be defined by both libraries.
I'm not sure if some linkers only treat this as a warning, instead of
an error, but even this seem to be unwanted.

One solution would be to introduce a namespace for all gnulib
functions, e.g., in gnulib.h (which would be included by all .c/.h in
gnulib) say:

#ifndef GLFP
/* GNULib Function Prefix */
#define GLFP gl_
#endif

#ifndef GLF
/* Add GNULib Function Prefix to function name */
#define GLF(x) GLFP##x
#endif

and then in strdup.c it should say:

char *GLF(strdup) (const char *s);

and in strdup.h (if there was one) it should say:

char *GLF(strdup) (const char *s);
#define strdup GLF(strdup)

Then I can put

#define GLFP gss_

in config.h in my GSS library and

#define GLFP gsasl_

in config.h in my GSASL library, and things will work.

I'm sure there is an easier solution.

(Using weak symbol definitions could work, but is this portable?)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]