Alex F
Alex F

Reputation: 43331

VC++ 2010 SDK for VC++ 2008, 2005 clients

I want to write SDK using Visual C++ 2010, which can be used by VC++ 2010 clients, and also old VC++ version clients. Let's say, I want to have it compatible for 2005 and 2008 versions. SDK contains several h, lib and dll files. Libraries have exported C++ classes and global functions. Public SDK interface (h-files) doesn't contain any feature that is not supported in previous VC++ versions. Internal SDK implementation may contain such features (like Lambda expressions, rvalue references etc.).

Some public SDK methods have callback interface parameters. Callback interfaces are defined in my h-files, implemented in the client code and passed to my methods. Can this be a problem?

I made several small tests and found that it works. Does anyone know any problem with using VC++ 2010 SDK by C++ clients, written in old VC++ versions?

Upvotes: 2

Views: 214

Answers (1)

Hans Passant
Hans Passant

Reputation: 942197

Key principles:

  • You cannot expose any objects from the standard C++ library (std::string etc), their layout is not compatible
  • You cannot use exceptions, SEH is okay
  • You cannot return any pointers that require the client code to release the pointed-to resource
  • You should build with /MT so the client doesn't have a headache digging up the required CRT version
  • You are generally okay with object layout between 2003 through 2010 as long as you can ensure it is not affected by compiler settings other than /Zp. Virtual inheritance has been troublesome. Verify that sizeof yields the same size regardless of the selected configuration.

COM is a good way to ensure maximum compatibility.

Upvotes: 2

Related Questions