1

I wanted to ask a question regarding good Api desing in C++. I want to expose some functionality through an API which will be provided as a shared object/dynamic library in unix and ios however this API will need to initialise some classes that implement the functionality and those objects will need to persist among different API calls for the functionality to be correct. So the API code will need to dynamically allocate objects and maintain the pointers, which is the point of my question: should the API maintain those pointers as static variables? is that considered a sane approach in this scenario? As far as I understand an API should be stateless for issues that occur with visibility and linkage however it is pretty much guaranteed that only a single process will ever call this library at any time.

computador7
  • 170
  • 6

0 Answers0