cppclean
cppclean copied to clipboard
Dealing with defines
If one includes a header where a macro is defined, cppclean
will not be able to detect that the header can actually be needed. This may be clearer with the following dummy example.
Example:
foo.h
#ifndef FOO_H
# define FOO_H
# include "bar.h"
class Foo
{
public:
Foo () : bar (BAR) {}
private:
int bar;
};
#endif //! FOO_H
bar.h
#ifndef BAR_H
# define BAR_H
# define BAR 1
#endif //! BAR_H
Running cppclean
gives:
$ cppclean --verbose .
Processing ./bar.h
Processing ./foo.h
./foo.h:4: 'bar.h' does not need to be #included
This may be something to add to the "planned" features, unless this requires some analysis that this tool is not meant to achieve. If that's the case, this may be worth noting somewhere in the documentation/help message.
Thanks for reporting this. I don't have time to look at this in the near term, but, I've added you as a collaborator to this repository.
Hi,
The same goes if you have for example:
string.h
using MyString = std::string;
main.cpp
#include "string.h"
void run() {
MyString hello("Hello world");
}