DEV Community

[Comment from a deleted post]
Collapse
 
theldoria profile image
Theldoria

Yes, the target language must be supported, but most common languages are already. If not, you would get your hands dirty providing one, and swig is not simple in that regard.

Apart from that, configuring swig can be as simple as defining your module name and specifying your include file: thus it can be as short as 3 lines of swig source. That, of course, depends on your interface design. If it gets too fancy, you have to give swig some hints in how to wrap. That's mostly because as developer you do not have to give all information about how to use a function to the compiler. One simple example for this is a pointer argument: is it an input to the function, an output or both?

And yes, swig syntax is not trivial if you leave the most common cases.

Regarding the compiler scope: That is also possible. Swig generates source code for C or C++. All you need is an additional wrapper-generate step, which should be handled in Makefile (or whatever build tool you use). And you can generate the wrapper and provide it, thus that one can compile without needing swig, e.g. in order to install. I do that, and I have automake files detecting if swig is available. In that case, the wrapper gets regenerated, otherwise I use the provided one. Or I might have misunderstood you...

Having said all this, I still find your article interesting and valuable. Having alternatives is always useful.

 
foxtacles profile image
Christian Semmler

Ah, I see! Thanks for the additional information. I will have to take a closer look at swig the next time I need such a solution.