On Fri, 26 Mar 2004 12:04:28 +0900
In article <f83335be.0403251902.40fd22c9 / posting.google.com>
[Ruby/DL and C++ libraries]
google / redheendran.com (Bheeshmar Redheendran) wrote:

> extern "C" void place( const std::string &text)
> {
>         std::cout << text << std::endl ;
> }
 :
> It works with C functions (change the "const std::string &" to a
> "const char *" and it's all good).
> 
> I have a feeling this can work with the write typealias and encoding
> functions, but I'm fairly new to Ruby and would appreciate any
> pointers.

A const std::string & is not a const char *.
C (dl.so) doesn't know how to construct/destruct std::string.

Use C-compatible types only, or write an extension library using
Ruby APIs. SWIG is one of nice solution I think.

To write a generic C++/Ruby interface is as hard as to write a
C++ compiler.


--[ Tietew ]-------------------------------------------------------
Mail: tietew / tietew.net / tietew / raug.net
Web : http://www.tietew.net/  (Tietew Windows Lab.)
PGP fingerprint: 26CB 71BB B595 09C4 0153  81C4 773C 963A D51B 8CAA