From: Robert Feldt Date: 2000-09-22T17:40:06+09:00 Subject: [ruby-talk:5061] Proposal: Add rubycpp.h or include in ruby.h Hi, I think it would be nice if people can easily write ruby extension in C++ so why not include following file (rubycpp.h) in distr or even include the two defines in ruby.h? At least there should be a note in the FAQ on how to build C++ extensions... rubycpp.h: #ifndef _RUBYCPP_H #define _RUBYCPP_H /* Extra stuff needed to build a C++ Ruby extension (.cc/.cpp/.cxx file): * * 1. Wrap methods in RB_METHOD when adding them with rb_define_method et * al. Example: * rb_define_method(cMyClass,"mname",RB_METHOD(mymethod_func),0); * * 2. Wrap finalizers in RB_FINALIZER when using Data_Wrap_Struct et al. * Example: * Data_Wrap_Struct(cMyClass,0,RB_FINALIZER(mc_free),mc_struct); * * 3. Attach 'extern "C"' to the init function. Example: * extern "C" void Init_MyCppExtension() */ #define RB_FINALIZER(func) ((void (*)(...))func) #define RB_METHOD(func) ((VALUE (*)(...))func) #endif Regards, Robert