Jamie Lokier <ja...@shareable.org> writes: > Sheng Yang wrote: >> 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" >> "Command syntax:\n" >> #define DEF(option, callback, arg_string) \ >> " " arg_string "\n" >> #include "qemu-img-cmds.h" >> #undef DEF >> #undef GEN_DOCS >> .... >> >> Seems gcc take "printf" as a marco. I added a "#undef printf" before the >> line, >> then it works... >> >> So any clue on what's happened and how to fix? > > You can't have preprocessor directives inside the arguments of a macro > call. Yes it's occasionally annoying like this. > > You can prevent the macro call without #undef by writing: > > (printf)("qemu-img version " ...etc)
Yup. > I'm not sure if Glibc is compliant with ISO C by > making printf into a macro that takes arguments. It is. 7.1.4 "Use of library functions" says "Any function declared in a header may be additionally implemented as a function-like macro defined in the header". > Certain functions such as putchar() are specified as being allowed to > be macros, which implies the other standard functions aren't. You mean putc(), don't you? 7.19.7.8: The putc function is equivalent to fputc, except that if it is implemented as a macro, it may evaluate stream more than once, so that argument should never be an expression with side effects. The general license-to-macro in 7.1.4 wouldn't allow a macro that evaluates the argument more than once, so we need a special license here.