Cpp clean tells me I need to #include something that I can forward declare.
Consider the following:
class Blah;
class Foo: public Bar{
public:
Foo();
virtual bool doSomething(Blah* blah);
};
Cppclean thinks that I need to #include "blah.h" even though I'm only using it in pointer form: "Foo.h:1: 'Blah' forward declared, but needs to be #included"
The code compiles fine with the forward declare.
I can't reproduce this:
$ cat Foo.h
class Blah;
class Foo: public Bar{
public:
Foo();
virtual bool doSomething(Blah* blah);
};
$ ./cppclean Foo.h
My examples wasn't good. I'll need to look further into this to work out what's going on, but may not have time. My project is very large so it could be very difficult to reduce it to a Minimal, Complete, and Verifiable example Is there a chance that cppclean could give the reason behind its conclusions? Like, it says something needs to be #included, can it give the location of the code that requires the #include, as well as the location of the forward-declare that it gives now?
I've got this kind of behaviour in specific templates. Ex :
class Data;
class Toto {
QPointer<Data> _socket
}
QPointer stores a pointer, it doesn't need access to Data implementation. This is the same for many smart pointers classes.
Would something that was forward declared but needs to be included even compile?
The following might help.
This works:
class MyCoolClass;
int do_something(MyCoolClass * ptr);
but this raises 'MyCoolClass' forward declared, but needs to be #included:
class MyCoolClass;
template <typename T>
T do_something(MyCoolClass * ptr)
{
// whatever
return 0;
}