|
From: | Stefan Weil |
Subject: | Re: [Qemu-devel] [PATCH] Use standard header for offsetof |
Date: | Fri, 06 Jun 2008 21:44:42 +0200 |
User-agent: | Mozilla-Thunderbird 2.0.0.14 (X11/20080509) |
Anthony Liguori schrieb:
Stefan Weil wrote:Anthony Liguori schrieb:I don't understand why you're adding #include <stdef.h> to files that do not define offsetof. What's the rationale for that?Regards, Anthony LiguoriThere were several possible ways to replace the defines for offsetof. After removing the defines, I could 1) include stddef.h at the places where offsetof was defined formerlyThis seems like the most logically thing to do to me. Otherwise, you're unnecessarily increasing the number of #include's in C files.
exec-all.h is one of these places. Adding #include <stddef.h> there reduces the number of #include statements in C sources, but now all sources which need exec-all.h also include stddef.h during compilation.
So this increases the number of included headers during a compilation.If you prefer source files without many includes, you can put all system includes in some central project headers. Many projects do this, and Qemu's qemu-common.h is an example for this approach. You could add the #include
for stddef.h there.I prefer minimized dependencies and short compile times, so I include system headers only at the places which need them.
The choice between both alternatives also depends on your compiler: nowadays most C compilers are clever enough not to parse a system header file more than once while compiling a C source which has several references to it. This is in favour of my prefered choice. But other compilers use precompiled headers, and for MS C with precompiled headers, few large header files are better. So there is no clear winner for all situations.
Qemu has no clear strategy for header file inclusion: qemu-common.h is used by many source files and includes stdio.h,
but some files (for example osdep.h) include both qemu-common.h and stdio.h. Regards Stefan
[Prev in Thread] | Current Thread | [Next in Thread] |