-
Notifications
You must be signed in to change notification settings - Fork 1
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
C/C++ include directives and explicitness #19
Comments
I totally agree on advising against omnibus headers of the sort of |
More refs, now focusing on self-sufficient headers: |
I presume this could be treated as an upstream bug. Nevertheless, good practice (and common sense?) dictates avoidance of omnibus header abuse. Another example is the |
Looking at this the other way around, i.e. redundant/unnecessary included headers, the |
Someone may be tempted to give for granted the transitiveness of included headers under the assumption that usage requirements, once being reflected in the public API, are automatically propagated. Example: // file "FancyInterface.hpp"
#include <SomeFancyDependency.hpp>
class FancyInterface
{
public:
void doSomething(SomeFancyDependency & obj);
}; Let's say I'm an user of this interface and I want to invoke an implementation of FancyInterface::doSomething. The signature tells me it introduces the SomeFancyDependency. I am pretty safe to include FancyInterface.hpp and assume everything will work. Now, see what happens in the following example: // file "FancyInterface.hpp"
class SomeFancyDependency; // forward declaration
class FancyInterface
{
public:
void doSomething(SomeFancyDependency * p_obj);
}; Since Edit: actually, |
Also affects |
From #12 (comment):
I think this is worth a mention in our guides. Two more situations I recently ran into:
<yarp/dev/CanBusInterface.h>
is (surprise!) not included in<yarp/dev/all.h>
The latter means that we may want to avoid omnibus headers of the sort of
xxx/all.h
. Is this acceptable?Note: also reflect conclusions of #12.
The text was updated successfully, but these errors were encountered: