[Mono-list] SWIG, C++, templates and generics.
kumpera at gmail.com
Fri Jan 16 13:10:38 EST 2009
On Fri, Jan 16, 2009 at 2:19 PM, fevans <fevans at harris.com> wrote:
> I posted a message similar to this in the SWIG forum, so I suppose I'm
> of cross-posting.
> I think mono would benefit, more than any other stack, from an investment
> SWIG or some similar technology. http://www.swig.org
> For better or worse Linux is pretty much a C++ domain. There are some
> aspiring stacks out there, but thus far none have gained much traction. The
> Mono stack is gaining adoption simply because despite all the FUD Mono
> simply works, period.
> Hence the need for C++ interoperability. For those not familiar with SWIG,
> here's a brief introduction:
> SWIG is a partial C/C++ compiler which takes C/C++ header files and
> generates two outputs:
> 1. A C++ wrapper source file to include in your library (mylib_wrap.cc), as
> well as C# files which will invoke the C++ library. Its simple and for the
> most works incredibly well.
> There are however some limitations. It fully supports C, and somewhat
> supports C++. In the domain of C++, templates are supported but its a
> Now, the thing to keep in mind is that SWIG is designed to generate
> for multiple languages. Java, python, csharp, perl, and many more. As such
> its architecture is somewhat encumbered by the fact that not all target
> languages support the same constructs.
> It seems to me the mapping of C++ templates to c# generics holds some
> exciting possibilities. I would think that the SWIG %template directive,
> some derivative of it could be used to push template instantiation further
> into the runtime domain (away from compile time).
> Unfortunately, making this happen is well beyond my abilities. So at this
> point I'm simply throwing the idea out for discussion.
C++ templates must be instantiated at compile time as they are, in the end,
just an ugglified macro
Thou I agree with you that the mono to c++ binding story could be a lot
better than it currently is.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-list