On 09/06/2017 04:10 PM, Eric Blake wrote: >> I'm not a fan of including header files from other header files, so >> changing the include order in the .c files sounds like the better >> solution to me. > > Eww. I like headers to be self-contained. Other than stuff we get from > osdep.h (which we know is included by EVERY .c file), I prefer that if a > header uses another type, then it guarantees that an idempotent > inclusion of a header that declares that type is also present in the > header file, rather than forcing .c files to know which order to include > things in.
The qemu tree-wide policy appears to be that a header should be self-contained (order of inclusion in .c files shouldn't matter). Also, if header A only uses 'SomeType *', it can either get the definition of SomeType from header B, or we can add the typedef to typedef.h at which point both header A and B get the typedef from there (that is, typedef.h is great for breaking what would otherwise be cyclic inclusion of mutually-recursive types across different headers, as well as a way to speed up compilation when a typedef is sufficient rather than a full definition). -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature