[libvirt] [RFC PATCH] build: consistently use C99 varargs macros

Eric Blake eblake at redhat.com
Mon Mar 1 17:42:51 UTC 2010

According to Daniel Veillard on 3/1/2010 10:13 AM:
> On Mon, Mar 01, 2010 at 08:04:35AM -0700, Eric Blake wrote:
>> Prior to this patch, there was an inconsistent mix between GNU and
>> C99.  For consistency, and potential portability to other compilers,
>> stick with the C99 vararg macro syntax.
>> -#define virStorageReportError(code, fmt...)                             \
>> +#define virStorageReportError(code, ...)                                \
>>      virReportErrorHelper(NULL, VIR_FROM_STORAGE, code, __FILE__,        \
>> -                         __FUNCTION__, __LINE__, fmt)
>> +                         __FUNCTION__, __LINE__, __VA_ARGS__)
>>  int virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
>>                                   const char *configDir,
>   That sounds a good idea, since mingw is the other compiler we use now,
> we just need to make sure it grok it, can you confirm ? google()[1] on
> the topic seems to be a post from you so I assume you can give a
> definite and quick answer :-)

mingw implies either gcc (supports both syntax styles) or MSVC.  I don't
use MSVC, but a google search[1] found a thread that implies that MSVC
sort-of understands C99 variadic macros as of 2005, but definitely does
not grok gcc variadic macros.  That page also states MSVC has bugs if
__VA_ARGS__ is not the last thing in the expansion, but that appears
irrelevant to libvirt's usage.

MSVC has enough other issues (the biggest in my mind being that it is not
free software, but it has a spate of other standards-compliance issues)
that I'm okay with requiring gcc for doing a mingw compile of libvirt.
But it is still nicer to stick to standards rather than gcc extensions,
when appropriate.

At any rate, it appears I have agreement with the cleanup, so I will
continue on with the rest of the patch and post the entire thing for
review later on.  Should I break it into one directory per patch, or
condense everything into a single giant patch?

[1] http://www.codeguru.com/forum/showthread.php?t=468033

Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 320 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100301/12ce86bd/attachment-0001.sig>

More information about the libvir-list mailing list