Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nd5se-0008AW-5c for qemu-devel@nongnu.org; Thu, 04 Feb 2010 12:52:40 -0500 Received: from [199.232.76.173] (port=46782 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nd5sd-00089o-HW for qemu-devel@nongnu.org; Thu, 04 Feb 2010 12:52:39 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nd5sb-0002Sp-Py for qemu-devel@nongnu.org; Thu, 04 Feb 2010 12:52:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60076) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nd5sb-0002Sf-Bu for qemu-devel@nongnu.org; Thu, 04 Feb 2010 12:52:37 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] "Enable _FORTIFY_SOURCE=2" result in building failure for qemu-img.c References: <201002041504.52626.sheng@linux.intel.com> <20100204121027.GA10297@shareable.org> Date: Thu, 04 Feb 2010 18:52:31 +0100 In-Reply-To: <20100204121027.GA10297@shareable.org> (Jamie Lokier's message of "Thu, 4 Feb 2010 12:10:27 +0000") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jamie Lokier Cc: "Kirill A. Shutemov" , Anthony Liguori , Juan Quintela , qemu-devel@nongnu.org, Sheng Yang Jamie Lokier 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.