From: Alex Gutteridge Date: 2007-06-26T09:08:17+09:00 Subject: Re: Name clash in C extension On 25 Jun 2007, at 20:04, Francis Cianfrocca wrote: > On 6/25/07, Alex Gutteridge wrote: >> >> Hi, >> >> I'm trying to write an extension interfacing with the C iGraph >> library (http://cneurocvs.rmki.kfki.hu/igraph/). Unfortunately the >> iGraph header files define a macro called TYPE which clashes with the >> TYPE macro defined in ruby.h. Both headers are obviously required to >> compile my extension. > > What happens if you define a wrapper for the calls you make to the > IGraph > liibrary? That way you include only the wrapper's header in the > extension's > main source file (the one that includes ruby.h and defines > Init_xxx). You'll > have to massage all data items between Ruby-land and C in the > wrapper as > well. I took this approach in the EventMachine library (where it > has an > additional benefit because the wrapper is in C, but the extension > code is > all in C++, so the wrapper approach avoids exposing decorated > symbols in the > compiled extension). Thanks for the pointer. I'd been trying to shortcut and use SWIG to generate the extension, but it looks like I will have to abandon that for the time being anyway (too complicated, makes my head hurt). I will have a look at EventMachine and see if I can use the same wrapper technique here. Alex Gutteridge Bioinformatics Center Kyoto University