Avoid issue with pp-directive in macro
PATCH 1/1 Avoid issue with pp-directive in macro
When building for SLES10, I ran into a build failure which results from printf being a macro, and two files which have an #include preprocessing directive within the macro arguments. There are other pp-directives,but the #include was the only one causing problems. (This was with gcc 4.x btw.)
It is undefined behavior to include pp-directives within macro arguments, and pretty much any of the std-c defined functions can be implemented as macros, so this patch avoids the issue by ensuring we are not using the macro version in the problematic cases.
qemu-img.c | 2 +- vl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
qemu-img.c +1 -1
@@ -58,7 +58,7 @@ static void format_print(void *opaque, const char *name)/* Please keep in synch with qemu-img.texi */ static void help (void ) { -printf ("qemu-img version " QEMU_VERSION ", Copyright (c) 2004-2008 Fabrice Bellard\n" + (printf)("qemu-img version " QEMU_VERSION ", Copyright (c) 2004-2008 Fabrice Bellard\n" "usage: qemu-img command [command options]\n" "QEMU disk image utility\n" "\n"
vl.c +1 -1
@@ -4337,7 +4337,7 @@ static void version(void)static void help (int exitcode) {version (); -printf ("usage: %s [options] [disk_image]\n" + (printf)("usage: %s [options] [disk_image]\n" "\n" "'disk_image' is a raw hard image image for IDE hard disk 0\n" "\n"
Quoted 6 lines · Bruce Rogers
When building for SLES10, I ran into a build failure which results from printf being a macro, and two files which have an #include preprocessing directive within the macro arguments. There are other pp-directives,but the #include was the only one causing problems. (This was with gcc 4.x btw.)
It is undefined behavior to include pp-directives within macro arguments, and pretty much any of the std-c defined functions can be implemented as macros, so this patch avoids the issue by ensuring we are not using the macro version in the problematic cases.
Signed-off-by Bruce Rogers <[email protected]>
I'd rather just use a %s. (printf) looks odd.
Regards,
Anthony Liguori