[gclist] Problems compiling with Xlib
Fri, 07 Apr 2000 22:07:27 -0400
John Palmieri wrote:
> Hello, I'm new to this list. I am writing a C++ program under linux
> that uses Boehm-Demers-Weiser conservative garbage collector. The code
> was compiling fine when I was just writing to the console but now I have
> the backend stuff done I started to move everything to an X display. I
> have read somewhere that X uses GC.
Yes, X defines "GC"... but I believe it means "graphics context" in that
scope. Xlib doesn't do any garbage collection.
> Consequently I am getting duplicate
> symbol compiling errors (I have gc_cpp.h included in mriIObject.h):
> Is there a way around this? I don't want to use Xlib's defines in the
> backend because I want to keep it frontend independent (Say someone
> wants to create a SVGALib frontend as opposed to an X frontend). Any
That's why the C++ language introduced namespaces, to avoid that sort of
collision. But if you are using plain C you are a little bit stuck...
though all hope is not lost.
If you can organize your compilation units in such a way that one source
file never includes both gc.h and Xlib.h, you can cleanly avoid the
problem. That's your best alternative.
If you absolutely cannot avoid #including these together, you may be
able to use preprocessor tricks to hide one of the GC symbols.