From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K4hs5-0002ZM-VI for qemu-devel@nongnu.org; Fri, 06 Jun 2008 15:45:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K4hs3-0002Z0-Nl for qemu-devel@nongnu.org; Fri, 06 Jun 2008 15:45:08 -0400 Received: from [199.232.76.173] (port=40071 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K4hs3-0002Yu-Ga for qemu-devel@nongnu.org; Fri, 06 Jun 2008 15:45:07 -0400 Received: from moutng.kundenserver.de ([212.227.126.174]:51148) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K4hs3-0008MZ-1K for qemu-devel@nongnu.org; Fri, 06 Jun 2008 15:45:07 -0400 Message-ID: <484993AA.2050603@mail.berlios.de> Date: Fri, 06 Jun 2008 21:44:42 +0200 From: Stefan Weil MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Use standard header for offsetof References: <4842DE67.9090207@mail.berlios.de> <484596C2.8030908@codemonkey.ws> <4845B193.8030209@mail.berlios.de> <4845B6A4.2070301@codemonkey.ws> In-Reply-To: <4845B6A4.2070301@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Anthony Liguori schrieb: > Stefan Weil wrote: >> Anthony Liguori schrieb: >>> >>> I don't understand why you're adding #include to files >>> that do not define offsetof. What's the rationale for that? >>> >>> Regards, >>> >>> Anthony Liguori >>> >> There 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 formerly > > This 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 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