Skip to content

A library PoC with C++ interface, easy to write, easy to use, yet highly compatible across compiler versions

License

Notifications You must be signed in to change notification settings

mkrevuelta/CppLibraryInterfacePoC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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:

NEW: I'm taking all this theory to practice in a real library:

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!

About

A library PoC with C++ interface, easy to write, easy to use, yet highly compatible across compiler versions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published