On Thu, 12 Jan 2023 at 15:14, Daniel P. Berrangé <[email protected]> wrote:
>
> On Thu, Jan 12, 2023 at 08:51:26AM -0500, Michael S. Tsirkin wrote:
> > On Thu, Jan 12, 2023 at 12:50:05PM +0100, Markus Armbruster wrote:
> > > docs/devel/style.rst mandates:
> > >
> > >     The "qemu/osdep.h" header contains preprocessor macros that affect
> > >     the behavior of core system headers like <stdint.h>.  It must be
> > >     the first include so that core system headers included by external
> > >     libraries get the preprocessor macros that QEMU depends on.
> > >
> > >     Do not include "qemu/osdep.h" from header files since the .c file
> > >     will have already included it.
> > >
> > > A few violations have crept in.  Fix them.
> > >
> > > Signed-off-by: Markus Armbruster <[email protected]>
> > > Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
> > > Reviewed-by: Bin Meng <[email protected]>
> > > Reviewed-by: Taylor Simpson <[email protected]>
> > > Reviewed-by: Alistair Francis <[email protected]>
> >
> > With my awesome grep skillz I found one more:
> > $ grep -r --include='*.h' qemu/osdep.h
> > include/block/graph-lock.h:#include "qemu/osdep.h"
> >
> > Looks like all C files must include qemu/osdep.h, no?
>
> Yes, and IMHO that is/was a mistake, as it means our other header
> files are not self-contained, which prevents developer tools from
> reporting useful bugs when you're editting.

The underlying requirement is "osdep.h must be included
before any system header file". "Always first in every .c file"
is an easy way to achieve that, and "never in any .h file" is
then not mandatory but falls out from the fact that any
such include is pointless and only serves to increase
the compilation time (and to increase the chances that
you don't notice that you forgot osdep.h in your .c file).

If there's a better way to do this (e.g. one which meant
that it was a compile error to put osdep includes in the
wrong place or to omit them) then that would certainly
save us periodically having to do this kind of fixup commit.

thanks
-- PMM

Reply via email to