My advice on implementing stuff in C:
My advice on implementing stuff in C:
Posted Oct 15, 2010 21:44 UTC (Fri) by cmccabe (guest, #60281)In reply to: My advice on implementing stuff in C: by HelloWorld
Parent article: Russell: On C Library Implementation
Your comment is particularly silly because Rusty isn't even talking about how libraries are implemented. He's talking about the API that you should present to users, and how the library should be built and packaged. Almost all of his comments apply to C++ libraries just as much as C libraries.
C++ libraries pretty much *have* to present a C-style interface to the world. Firstly, if you want your library to be used in a language like Ruby, you need a C-style binding, because C++ bindings are not available. Secondly, using C++ constructs like templates and virtual classes in the API force you to rebuild your entire application every time the library version changes. Thirdly, there are many different dialects of C++ in use. Some people like exceptions; other people never use them. (Google, for example, does not allow its C++ programmers to use exceptions.) Some people compile with -fno-rtti, other people never do. Some people use smart pointers; other people prefer to let the caller manage the memory. You're never going to write a C++ API that will please all of these people. So just create a C API and be happy.
