On Wed, Apr 14 2021, Jeff King wrote: > On Tue, Apr 13, 2021 at 02:07:13PM -0700, Junio C Hamano wrote: > >> Jeff King <peff@xxxxxxxx> writes: >> >> >> + * We restrict this trick to gcc, though, because while we rely on the >> >> + * presence of C99 variadic macros, this code also relies on the >> >> + * non-standard behavior of GCC's __VA_ARGS__, allowing error() to >> >> + * work even if no format specifiers are passed to error(). >> >> The last part of this comment is puzzlling. Do we ever call error() >> without any format specifier? There may be GCC-ism behaviour around >> the __VA_ARGS__ stuff, but are we relying on that GCC-ism? > > I took "format specifier" to mean the "%" code within the format. E.g.: > > error("foo"); > > has no format specifier, and thus no arguments after the format. But > every call will have at least the format string itself. > > AFAIK, portably using variadic macros means you need there to always be > at least one argument. Hence "error(fmt, ...)" is wrong (the "..." may > have no arguments) but "error(...)" is OK (you always have a format > string). I'm not sure if Ævar knows about some other portability gotcha, > or if he just didn't realize that this was written in the portable way. No, I just read elsewhere that GCC had non-standard behavior, and didn't look carefully at your implementation, but since it explicitly depended on GNUC etc. understood it to mean it was GCC-specific, not just C99-specific. So it can simply be changed to depend on HAVE_VARIADIC_MACROS instead?