Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

mkrevuelta/CppLibraryInterfacePoC

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
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

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.