# Communication between different C extensions

**URL:** <https://www.ruby-forum.com/t/communication-between-different-c-extensions/83652>\
**Category:** Ruby\
**Created:** [January 28, 2007, 12:24pm UTC](https://www.ruby-forum.com/t/communication-between-different-c-extensions/83652 "2007-01-28T12:24:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnuvince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/82dd89/32.png) [@gnuvince](https://www.ruby-forum.com/u/gnuvince)\
**Post date:** [January 28, 2007, 12:24pm UTC](https://www.ruby-forum.com/t/communication-between-different-c-extensions/83652/1 "2007-01-28T12:24:49Z")

</div>

Hello !

A long time ago, I was bitten hard by interoperability between  
different C extensions that need to access each others internals. As at  
that moment I was controlling the source code of all extensions, I got  
away with a (simple ?) workaround.

Now is time for me to get bitten again. I’m currently writing a Ruby  
wrapper for a C++ library providing simple symbolic calculus (and  
evaluation). The extensions provides functions to apply a formula to a  
great number of numbers, a bit like the following:

apply(“x + y”, ‘x’ =\> [1,2], ‘y’ =\> [3,4])  
=\> [4,6]

I want to be able to interface that with the common libraries for  
manipulating data (Narray, ruby-gsl and Dobjects, a library used by  
Tioga). However, I’m not aware of any way to do this ‘cleanly’. Sure, I  
can hack the data structures from the headers of these extensions, but  
that means breaking binary compatibility everytime a header changes -  
not very much something I like.

Is there a better way to do so ? Going through Ruby arrays isn’t an  
option for speed issues (very expensive to convert a double \* to a VALUE  
array and back to double \*…). Any ideas ?

Thanks,

Vince
