Q:

Exposing an API for DLLs from an app

I am developing a plugin system for an application. The idea is to load some functions from plugins (loaded as DLLs) and use those functions in our scripting language hosted in app. I have to expose an API for the DLLs for them to interact with the app. The API may change overtime and the older DLLs should not be invalidated. Please give me some leads to read up on or please suggest ideas. Thanks.
Duminda

A:

Here are some ideas:

Make the API fully compatible with C. No classes, no STL types, all functions declared extern "C".
For versioning, embed the API version number in the function and struct names. Once a version has been released, the function signatures and type definitions can not be changed without the risk of breaking backward compatibility.
For convenience, you could provide a set of macros that map a function-name-without-version-number to a versioned function name. When the macros are updated for a new version, this will not break compatibility with older versions, but it will make the client code easier to read.

