On Tue, Oct 30, 2018 at 10:41 PM Anders Selhammer
<[email protected]> wrote:
> Otherwise, other who use servo will know about the structure in struct servo, 
> which is not the point.

I don't understand this concern. With my patch, non-servo code that
includes servo.h still only sees the opaque forward-declared version
of servo. My patch doesn't make servo_private.h any more or less
accessible than before.

In other words, it should be fine for a private header to include the
public header. It's not ok for a public header to include a private
header.

> servo_private.h should not include servo.h

It's different than port_private.h. servo_private.h depends on
servo_state which is only declared in servo.h. port_private.h has no
dependencies on port.h (port.h doesn't define any types at all).

Each .h file should include the files it needs (or forward-declare
structs). You can't forward declare an enum, so it makes sense to
include servo.h. We shouldn't require that users of servo_private.h
use a specific non-alphabetical ordering of includes.

For example, nullf.c includes servo_private.h. It's only an accident
(alphabetical order) that servo_private.h is included after nullf.h
which includes servo.h. If nullf was instead called 'zzzf', then
servo_private.h would be included before 'zzzf.h' and the compilation
would break. We'd have to move servo_private.h out of alphabetical
order to be past zzzf.h.


_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to