Message ID | 1455818725-7647-3-git-send-email-peter.maydell@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 02/18/2016 11:05 AM, Peter Maydell wrote: > For C++ before C++11, <stdint.h> requires definition of the macros > __STDC_CONSTANT_MACROS, __STDC_LIMIT_MACROS and __STDC_FORMAT_MACROS > in order to enable definition of various macros by the header file. > Define these in osdep.h, so that we get the right header file > definitions whether osdep.h is being used by plain C, C++11 or > older C++. > > In particular libvixl's header files depend on this and won't > compile if osdep.h is included before them otherwise. > > Signed-off-by: Peter Maydell <peter.maydell@linaro.org> > --- > include/qemu/osdep.h | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) Reviewed-by: Eric Blake <eblake@redhat.com> > +/* 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 Style nit: In libvirt, we've grown used to writing: #ifndef ... # define ... #endif that is, use spacing to make it more visually obvious what level of conditional nesting is in effect during preprocessor lines. But short of a tree-wide change to enforce that style (which I'm not advocating), it's more of a food for thought comment, and has no bearing on taking this series as is.
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index cc055c9..c1b413d 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -28,6 +28,20 @@ #include "config-host.h" #include "qemu/compiler.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 */
For C++ before C++11, <stdint.h> requires definition of the macros __STDC_CONSTANT_MACROS, __STDC_LIMIT_MACROS and __STDC_FORMAT_MACROS in order to enable definition of various macros by the header file. Define these in osdep.h, so that we get the right header file definitions whether osdep.h is being used by plain C, C++11 or older C++. In particular libvixl's header files depend on this and won't compile if osdep.h is included before them otherwise. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> --- include/qemu/osdep.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)