[Mono-dev] C++ wrapper ?

Rafael Teixeira monoman at gmail.com
Fri Sep 2 09:13:18 EDT 2005

Just a tip

Using correctly the 

extern "C" { ...} 

construct in your "interfacefile_3" you may not need to write a c
wrapper ("interfacefile_2").

The main restriction is that:

"You can specify extern "C" for only one instance of an overloaded
function; all other instances of an overloaded function have C++

You can also read;


On 9/2/05, ivar at imaker.no <ivar at imaker.no> wrote:
> Hello,
> If I want to wrap a c++ class library what should I do ?
> For me it seems like I have to do the following:
> 1. Make a ANSI c interface file calling the C++ functions, interfacefile_1
> 2. use csharps DLLImport directive making a wrapper class i csharp,
> interfacefile_2
> But then I have still two problems
> I. A lot of arguments and return values are of C++ std template types,
> like vector, string etc.
> II. I must create the object in c++ before I can start to use it.
> A solution to both I and II is to make a simpler interface in C++ and
> adding a init function whichs creates the original object when called,
> interfacefile_3
> ?
> So then the call stack looks like:
> C++ class I want to use
> C++ wrapper to simplify arguments, and to add a functrion for creation of
> original class
> c wrapper to become compatible with the c# DLL import directive
> a c# wrapper using DLL import
> I know it is possible to skip c wrapper file and using the callnames of
> c++,  but since this is not compiler independent I prefer not to do it
> this way.
> So my question is: Is there no easier way to interface to c++ code ?
> Had it only been one class I think I could have used swig, but I donæt see
> how I can use swig when I have many C++ classes.
> Best regards
> IB
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

Rafael "Monoman" Teixeira
I'm trying to become a "Rosh Gadol" before my own eyes. 
See http://www.joelonsoftware.com/items/2004/12/06.html for enlightment.
It hurts!

More information about the Mono-devel-list mailing list