Thanks for concluding on this. I will rearrange the qnio_api.h header accordingly as follows:
+#include "qemu/osdep.h" +#include <qnio/qnio_api.h> <=== after osdep.h +#include "block/block_int.h" +#include "qapi/qmp/qerror.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qstring.h" +#include "trace.h" +#include "qemu/uri.h" +#include "qapi/error.h" +#include "qemu/error-report.h" <==== remove On Tue, Nov 15, 2016 at 11:20 AM, Stefan Hajnoczi <stefa...@gmail.com> wrote: > On Tue, Nov 15, 2016 at 11:00:16PM +0800, Fam Zheng wrote: >> On Tue, 11/15 14:45, Stefan Hajnoczi wrote: >> > On Tue, Nov 15, 2016 at 08:44:17PM +0800, Fam Zheng wrote: >> > > On Tue, 11/15 10:18, Stefan Hajnoczi wrote: >> > > > Fam, Markus: Unfortunately neither the clean-includes script nor its >> > > > patch series cover letter explains *why* osdep.h should be included >> > > > before system headers. >> > > >> > > I don't know Peter's exact intention either, but AFAICT it is about the >> > > few >> > > quirks in osdep.h: >> > > >> > > >> > > /* Older versions of C++ don't get definitions of various macros from >> > > * stdlib.h unless we define these macros before first inclusion of >> > > * that system header. >> > > */ >> > > #ifndef __STDC_CONSTANT_MACROS >> > > #define __STDC_CONSTANT_MACROS >> > > #endif >> > > #ifndef __STDC_LIMIT_MACROS >> > > #define __STDC_LIMIT_MACROS >> > > #endif >> > > #ifndef __STDC_FORMAT_MACROS >> > > #define __STDC_FORMAT_MACROS >> > > #endif >> > > >> > > /* The following block of code temporarily renames the daemon() function >> > > so the >> > > * compiler does not see the warning associated with it in stdlib.h on >> > > OSX >> > > */ >> > > #ifdef __APPLE__ >> > > #define daemon qemu_fake_daemon_function >> > > #include <stdlib.h> >> > > #undef daemon >> > > extern int daemon(int, int); >> > > #endif >> > > >> > > <...> >> > > >> > > >> > > /* Mac OSX has a <stdint.h> bug that incorrectly defines SIZE_MAX with >> > > * the wrong type. Our replacement isn't usable in preprocessor >> > > * expressions, but it is sufficient for our needs. */ >> > > #if defined(HAVE_BROKEN_SIZE_MAX) && HAVE_BROKEN_SIZE_MAX >> > > #undef SIZE_MAX >> > > #define SIZE_MAX ((size_t)-1) >> > > #endif >> > >> > This is exactly the kind of stuff we should not be doing to the libqnio >> > header file! >> > >> > Those redefinitions are useful for QEMU code. They should not be done >> > to third-party system headers though. >> >> But we still want to include osdep.h before libqnio pulls in stdint.h. If we >> don't make osdep.h the very first, that cannot be guaranteed. > > Thanks, that makes sense! > > I'll add a comment to clean-includes with this explanation of why > osdep.h must go before system headers. > > Stefan