I have an implementation file tomog.cpp that implements a class called Tomog where I need to include its header file which resides in another place.
How can I best specify the include file? I would not like to do
#include "../../tomso/tomography/tomog.hpp"
I wish to do instead
#include "tomso/tomography/tomog.hpp"
Add this to your compile flags:
-I /path/to/basefolder
...and it will include that path in the search path when opening include files.
1 Like
I am getting a bit confused now. I have a class that has to include several classes.
Had set up the class declaration and implementation in tomog.hh. Now I have the declaration and implementation in separate files tomog.hpp and tomog.cpp.
Originally I included
#include "tomso/verbosity/lglevel.hpp"
#include "tomso/raytrace/velmod.hpp"
#include "tomso/optimization/objfunc.hpp"
#include "tomso/optimization/modmisfit.hpp"
I am now wondering where I should put the include directives, in the .hpp or in the .cpp??
As long as your include files are protected from multiple inclusion, you can put #include statements in an include file without worry.