Reputation: 9144
I am developing C++ headers only library, lets call it PROJ. When a library header is including another, it uses:
#include <proj/foo.h>
And compiler (gcc and clang) have -I path-to-proj-parent
. Users of the library should also have parent of PROJ in their include search path.
My rationally for using this scheme is that after installing this library into proj
subdirectory of default-seachable parent (/usr/include/proj
or /usr/local/include/proj
), library user do not need to specify -I
option.
Is there cons to this scheme? Is using <foo.h>
without proj/
prefix is more conventional and recommended way?
Question is not about if installing in subdir or not (there will be proj
subdir), but rather how to refer to include-files.
Upvotes: 4
Views: 188
Reputation: 300349
If you look at boost, you will note that they use a similar scheme:
#include <boost/shared_ptr.hpp>
It has the advantage of preventing clashes with another similarly named file from another dependency.
However, in the case of boost, they take it one step further. If you include <x/y/z.hpp>
, then you are likely to be dealing with an entity named ::x::y::z
(be it function or class). That is, the way the directories in the project are laid out mimic the namespace organization. It's quite neat really to orient oneself.
Normally, most projects are stashed in subdirectories (and subnamespaces), but the most used ones are pulled into the boost
namespace for convenience, and thus they have headers living directly in the boost
folder. There are also some convenience headers (whose job is just to gather a smattering of other headers to pull them in all at once).
You may finally note, if you open a header file, than the include guards they use follow the exact same hierarchy:
#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
once again because it helps avoiding clashes since it's named after the very file it's in and there can be only one at that place in the whole Boost project (on case sensitive filesystems).
Upvotes: 3
Reputation: 13189
It is ok to have proj in the path if you create the proj directory when you install. In fact its a good way to prevent name collisions with other include files.
The name should not be something generic like "proj' though. It should be specific to the project.
Upvotes: 2