From: Joel VanderWerf Date: 2002-09-13T13:41:57+09:00 Subject: Re: a question about using inline.rb Maggie Xiao wrote: > Hi there, > > Is there anyone has used inline.rb to extend ruby in c? Should i include the > header file > inside the class? and should i include them just like in c code? For example: > #include > #include > > Thanks, > > Maggie > I don't know how inline.rb handles this, but cgenerator defines an include method that you can call in the context of your function definition (this is from examples/sample.rb): lib.define("distance").instance_eval { arguments "point *p1", "point *p2" return_type "double" scope :extern returns "sqrt(pow(p1->x - p2->x, 2) + pow(p1->y - p2->y, 2))" include "" } (This is just a C function, not a method, but cgenerator lets you define methods, too.) The include call propagates up to the library object, which generates the appropriate code in its main header file, and checks if you have already included .