John Bandela: Easy Binary Compatible C++ Interfaces Across Compilers
Channel: CppNow
Date: 2013-06-12

C++ is often perceived as hard to use and not as productive as other languages. One of the reasons for this is the lack of interoperability of binary components. When using a library, the user then either has to build from source (further complicated by the fact that there are multiple build systems) or the creator has to distribute multiple binaries. For example on Windows, one may have to distribute binaries for GCC Mingw, Visual C++ 2010 (release and debug, static and dynamic CRT), Visual C++ 2012, etc. There have been attempts to get around this problem. Options range from "extern C" functions, COM or XPCOM, or language extensions such as C++/CX. The above options either require compiler extensions or feel foreign and low-level to someone who is used to Modern C++.

With C++11 being more consistently implemented across more compilers, one can take advantage of features such as lambdas and variadic templates to create easy to define, use, and implement binary interfaces that will work across compilers.

This presentation will discuss the design and implementation of a library that has the following benefits:

* No external tools to run
* Define an interface once and use the definition for both implementation and usage
* Interfaces are easy to implement and use once defined
* Use std::string, std::vector, and std::pair in the interface
* Use real return types (not error codes)
* Use exceptions both in implementation and usage
* Binary compatible with COM
* Supports interface inheritance
* Supports implementation inheritance
* Implementation tested on Windows with Visual C++ executable and GCC .dll
* Implementation tested on Linux with GCC executable and Clang .so

During this presentation, will discuss how we go about implementing the above features, as well as look at some of the tradeoffs for this convenience. I also look forward to discussion with audience members about different approaches and ways in which this could be made better.
---

*--*

---