![swig software wrapper swig software wrapper](https://i.ytimg.com/vi/0pjQ5wXhuOg/maxresdefault.jpg)
Obviously, requiring a unique intermediate DLL for every language is undesirable… Whilst our goal is to be able to consume the C++ library only from C#, we still want to have the choice to expand to more languages in the future. It also seems to be specific to each target language, which would mean having a separate C layer for each language we wanted to target. The C layer that SWIG creates to sit between the C++ library and whatever language is consuming it is extremely human-unfriendly.
#SWIG SOFTWARE WRAPPER CODE#
We don’t want to have to downgrade to function pointers and lose the extra goodies that come with std::function, like being able to bind to member functions.Īnother problem I faced with SWIG was in the code it generated. “But”, I hear you say, “surely you’re not using STL containers in your public API?! Those aren’t safe to use across DLL boundaries, because their implementation is compiler-specific!” Well, yes…We make heavy use of std::function for passing call-backs to our code. One major downside of SWIG when it comes to wrapping C++ code is that it has very little support for STL containers. However, it wasn’t the only hurdle I encountered during the time I spent investigating SWIG as a potential solution to our problem. By itself, this isn’t too much of an issue. This means that extra time needs to be dedicated to just writing these configuration files. However, this is not always the case, especially for more complicated headers. For the most part, it can directly consume C and C++ headers and generate appropriate wrapper code for them. SWIG requires the user to create configuration files that declare what parts of the code to wrap. The main problem lies in the way that SWIG wraps C++ code. This seemed like a good place to start, but how good can the generated code really be for something that targets many different programming languages? The answer was, sadly, “not very”. SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. The first project I came across was one I had heard of numerous times before.
![swig software wrapper swig software wrapper](https://www.fmxexpress.com/wp-content/uploads/2020/09/pexels-abtin-mohebifar-3497985.jpg)
So, I set off to investigate these potential solutions. Simple enough, right? Surely a solution to make this a reality already exists? This is a perfectly reasonable assumption, and you would be absolutely right in thinking this.
![swig software wrapper swig software wrapper](https://user-images.githubusercontent.com/14304676/67872980-5ec03900-faf8-11e9-9a62-1de237b2b59d.png)
I joined REWIND a few months ago, and my first job here was a real doozy: make a library written in C++ usable in Unity.