阅读背景:

如果用户在使用Rice重新定义Ruby中的initialize(),则避免使用C ++代码中的Segfault

来源:互联网 

One problem I am struggling with while writing a C++ extension for Ruby is to make it really safe even if the user does silly things. He should get exceptions then, but never a SegFault. A concrete problem is the following: My C++ class has a non-trivial constructor. Then I use the Rice API to wrap my C++ class. If the user redefines initialize() in his Ruby code, then the initialize() function created by Rice is overwritten and the object is neither allocated nor initialized. One toy example could be the following:One problem I am struggling with while writing




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: