Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

In C++, is it possible to include all headers in all sub-folders of a folder?

#include <iostream>
#include<eigen3/Eigen/src/Core/Matrix.h> // does not define Eigen::StorageOptions

// need something like this
#include<eigen3/Eigen/src/ everything_in_here >

int main()
{
    Eigen::Matrix<double,2,2> mat;
    std::cout << mat(0,0) <<std::endl;
    return 0;
}

In there, I’m trying to build a matrix object and it always asks 6 template parameters with error message:

wrong number of template arguments (3, should be 6)

So I started adding them, 4th one is Eigen::StorageOptions and is not defined in the Matrix.h header. Also there are too many headers to search. So, can I include all files in there with a single #include?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

No, there isn’t. Only individual files can be included. (Though technically what that means is implementation-defined.) The preprocessor has no filesystem/directory concept. It considers the file names used in #include directives only as strings, not paths.

I am also not aware of any compiler extension to support this (although there may be ones).

You can generate the necessary #include directives in a script as a preparation step in the build process.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading