Skip to content
A library PoC with C++ interface, easy to write, easy to use, yet highly compatible across compiler versions
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Client
Foo
LICENSE
README.md

README.md

CppLibraryInterfacePoC

A Proof-of-Concept library with:

  • Mostly C++ interface (objects, move semantics)
  • Easy to write (real C++, no conversion to/from extern "C" functions)
  • Easy to use (objects are given away, managed by unique pointers)
  • Highly compatible across compiler versions from a given vendor (only requirement: C++11 or above)

This repository contains evolved versions of the examples I proposed in this presentation:

Foo library

The Foo library can receive or return the next data structures, or "messages":

  • StringMsg: a text string
  • NumbersMsg: an array of numbers
  • MultiMapMsg: a string-to-string multimap

Each type of message is wrapped in a class. With respect to the usage of C++, the main restriction is that the methods provide access to the data through C types (i.e., const char *). On the other hand, these classes are implemented with the PIMPL idiom and support move semantics. Thus, data can be passed with minimal overhead and, at the same time, the lifetime of objects is very easy to manage.

Client program

Sample program that calls every Foo function.

Both Foo and Client can be compiled for MSVC 2012 and MSVC 2019. Note that each Client project is configured to copy and use the DLL compiled with the other version of the compiler!

You can’t perform that action at this time.