• Forum
  • Lounge
  • Application/Private Level Includes in C+

 
Application/Private Level Includes in C++ Project

(I haven't been here in a while)

Ok, so I'm making a C++ project template: https://github.com/arnavb/cpp14-project-template

Said template is great, but I have one question. Where should application level includes go?

For example, consider my directory structure, which is:


root/
|
+--include/
+---project-name/
+----public_include.hpp
+----other_api_include.hpp
+--src/
+---public_include.cpp
+---other_api_include.cpp
+---impl_file.hpp <-- Implementation files
+---impl_file.cpp <-- Implementation for implementation file


Now my question is: Is this the best practice for placing application includes that are not part of the public API of the code? (I am using CMake, so I don't want to dump stuff in include/project-name since those includes will be installed in CMAKE_INSTALL_PREFIX/include.

What sort of structure do you guys use when you have to separate application level and library level (or private and public) includes?
Last edited on
If there's a single project in the repository (defining "project" as a set of sources that produce a single executable), I don't even bother with structuring internal inclusion. Files just directly include whatever they need wherever it is. This does mean that sometimes I'll get directives like #include "../foo/bar.h" , though.

If there's multiple projects in the same directory and they need to share some code, I'll usually put that in /common, following the same structure as above. As a rule, though, the stuff in /common cannot depend on anything outside of /common.
Last edited on
Topic archived. No new replies allowed.