I am currently developing an API and I now find useful to have an explicit split in my directory tree in order to separate public header files and private header and source files. This way, it is going to be easier to build both the public and the development (private) package for my SDK. I have now in mind two different options:
1)
.../LibName/Class.h
.../LibName/private/ClassImpl.h
.../LibName/private/LibName/ClassImpl.cpp
2)
.../public/LibName/Class.h
.../private/LibName/ClassImpl.h
.../private/LibName/ClassImpl.cpp
It would be nice to have files organized in the way 'Libname/FileName' at least for the public files, because this is the way include directives are in my code:
#include "LibName/FileName.h"
What do you think is the best option to organize the headers for an API? One of these two or maybe some other?
Thank you
I finally chosed the following structure:
.../include/LibName1/Class.h
.../include/LibName2/OtherClas.h
.../src/LibName1/ClassImpl.h
.../src/LibName1/ClassImpl.cpp
.../src/LibName2/OtherClassImpl.h
.../src/LibName2/OtherClassImpl.h
This way I can both separate public headers (include directory) and private source (src directory) and also reference the header files in the include directives without writing explicitly if they are public or private:
#include "LibName1/Class.h"
This structure (or a similar one) is also used in other libraries like Qt framework.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With