Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor includes of files and libraries #13

Open
tanya-kta opened this issue Sep 12, 2020 · 2 comments
Open

Refactor includes of files and libraries #13

tanya-kta opened this issue Sep 12, 2020 · 2 comments

Comments

@tanya-kta
Copy link
Member

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
Copy link
Member

kolayne commented Sep 19, 2020

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 added a commit that referenced this issue Sep 19, 2020
Please, note, that it is not related to #13
kolayne added a commit that referenced this issue Sep 19, 2020
Please, note, that it is not related to #13
@kolayne
Copy link
Member

kolayne commented Oct 3, 2020

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?..

kolayne added a commit that referenced this issue Oct 24, 2020
New includes appearance (with paths) may help when working on #4 and/or #13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants