Reputation: 6649
I am creating a C++ library for use by third parties. While I am familiar with creating C libraries I have little experience creating C++ libraries. My concern is that there are additional issues presented by C++ library APIs which I need to consider. Such as :
What must I consider above and beyond that which I must consider for C libraries?
Best Regards
Upvotes: 4
Views: 1906
Reputation: 441
C++ is a more complex language than C, so there are a lot more issues that you need to be aware of. There are always language neutral concerns like how to design a good public/private separation, documentation, versioning, maintaining backward compatibility, etc. But there also various C++-specific issues, such as const correctness, your use of templates, exceptions vs return codes, not exposing data members, your use of inheritance, considering copy constructors and assignment operators, use of pointers or references, default arguments, friends, use of inline, etc.
In full disclosure, I am the author of the book "API Design for C++". Without wanting to sound like I'm pushing the book, it does cover exactly the topic that you're asking about: how to design good APIs for C++. You can view the table of contents of the book to give you a good overview of the issues you should be considering. Also, the sample chapter includes a discussion of the pimpl idiom, which I personally like as a way to provide better encapsulation in C++.
http://www.apibook.com/blog/contents
Upvotes: 6
Reputation: 17918
Microsoft do provide design guidelines for class libraries, not sure if such exists for Linux as well, but these are general guidelines and should apply to various platforms.
http://msdn.microsoft.com/en-us/library/czefa0ke(v=vs.71).aspx
Upvotes: 0