physarumAdv / minds_crawl

Physarum polycephalum growth simulator on polyhedron surfaces written in CUDA C++
MIT License
4 stars 0 forks source link

Refactor includes of files and libraries #13

Open tanya-kta opened 4 years ago

tanya-kta commented 4 years ago

Check all includes and rewrite them to follow the rule: all files and libraries used in file A has to be included in file A, even if some of them are already included through other files. Also check for other problems such as unused includes. For example:

Incorrect:

//a.cpp
#include <cmath>

//using `cmath` functions
//b.cpp
#include "a.cpp"

//using `cmath` and `a.cpp` functions

Correct:

//a.cpp
#include <cmath>

//using `cmath` functions
//b.cpp
#include <cmath>

#include "a.cpp"

//using `cmath` and `a.cpp` functions
kolayne commented 4 years ago

Btw, the order of includes matters for CLion: if A is included in B, and you want to include both A and B to C, then you should include A first and B after that. Example:

// a.cpp
void f1() {}
// b.cpp
#include "a.cpp"

void f2()
{
    f1();
}
// c.cpp (bad)
#include "b.cpp"
#include "a.cpp"

// use f1, f2

// c.cpp (good)
#include "a.cpp"
#include "b.cpp"

// use f1, f2
kolayne commented 4 years ago

If there are, for example, "something.hpp" and "something.cpp" files, and the hpp file includes something which cpp wants to use, should we include it in cpp again?..