From: Gary Date: 2007-10-21T01:55:03+09:00 Subject: Re: Building an extension in C++ Thank you Robert! I agree and understand about catching and converting C++ exceptions to Ruby exceptions. Now, on to my next problem. When I try using new I get linker errors (grrr) extern "C" void Init_Test() { cTest = rb_define_class("Test", rb_cObject); try { int *x=new int; } catch (...) { } } I get the following errors: undefined reference to '___gxx_personality_sj0' undefined reference to 'operator new(unsigned int) undefined reference to '___cxa_begine_catch' undefined reference to '___cxa_end_catch' It compiles nicely if I replace: int *x=new int; with int *x=NULL -Gary On Oct 20, 9:05 am, Robert Klemme wrote: > On 20.10.2007 17:19, Gary wrote: > > > > > > > > > Thank you mental!!! It works. I should have figured it out myself, > > but I needed your help. > > > I'm I bit confused about a C-linkage interface to the C++ portion. Is > > this going to be more than wrapping the C++ calls in try catch(...) > > In other words having something like > > > extern "C" VALUE t_init(VALUE self) > > { > > //declare any Ruby C++ data conversion vars in C > > try > > { > > //call C++ functions > > } > > catch(...) > > { > > //process exceptions > > } > > //Do any data interactions between C++ and Ruby > > } > > > Once again, thanks! I spent several hours stumped. > > That'll probably suffice. You might get a bit better results by > catching explicit exception types and converting them to Ruby world > exceptions. Other than that your code should prevent any havoc caused > by C++ exceptions raised into the Ruby interpreter. > > Kind regards > > robert