{"thread":{"id":"55064","subject":"[PATCH] git-compat-util: always enable variadic macros","startedAt":"2021-01-28T05:29:16Z","lastAt":"2021-01-29T02:13:32Z","messageCount":3,"participants":["Jeff King","Junio C Hamano","brian m. carlson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"415479","messageId":"YBJLgY+CWtS9TeVb@coredump.intra.peff.net","threadId":"55064","inReplyTo":null,"subject":"[PATCH] git-compat-util: always enable variadic macros","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-01-28T05:28:33Z","receivedAt":"2021-01-28T05:29:16Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"We allow variadic macros in the code base, but only if there is fallback\ncode for platforms that lack it. This leads to some annoyances:\n\n  - the code is more complicated because of the fallbacks (e.g.,\n    trace_printf(), etc, is implemented twice with a set of parallel\n    wrappers).\n\n  - some constructs are just impossible and we've had to live without\n    them (e.g., a cross between FLEX_ALLOC and xstrfmt)\n\nSince this feature is present in C99, we may be able to start counting\non it being available everywhere. Let's start with a weather balloon\npatch to find out.\n\nThis patch makes the absolute minimal change by always setting\nHAVE_VARIADIC_MACROS. If somebody runs into a platform where it's a\nproblem, they can undo it by commenting out the define. Likewise, if we\nhave to revert this, it would be quite unlikely to cause conflicts.\n\nOnce we feel comfortable that this is the right direction, then we can\nstart ripping out all the spots that actually look at the flag, and\nremoving the dead code.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nWe've talked about this off and on for a few years. I don't have any\nimmediate plans for any features that need it, but let's get the ball\nrolling.\n\n git-compat-util.h | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 104993b975..5d5e47fbe2 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1176,9 +1176,12 @@ static inline int regexec_buf(const regex_t *preg, const char *buf, size_t size,\n #endif\n #endif\n \n-#if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__C99_MACRO_WITH_VA_ARGS)\n+/*\n+ * This is always defined as a first step towards making the use of variadic\n+ * macros unconditional. If it causes compilation problems on your platform,\n+ * please report it to the Git mailing list at git@vger.kernel.org.\n+ */\n #define HAVE_VARIADIC_MACROS 1\n-#endif\n \n /* usage.c: only to be used for testing BUG() implementation (see test-tool) */\n extern int BUG_exit_code;\n-- \n2.30.0.758.gfe500d6872\n"},{"id":"415485","messageId":"xmqq5z3hy4fq.fsf@gitster.c.googlers.com","threadId":"55064","inReplyTo":"YBJLgY+CWtS9TeVb@coredump.intra.peff.net","subject":"Re: [PATCH] git-compat-util: always enable variadic macros","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-01-28T06:13:29Z","receivedAt":"2021-01-28T06:14:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> We allow variadic macros in the code base, but only if there is fallback\n> code for platforms that lack it. This leads to some annoyances:\n>\n>   - the code is more complicated because of the fallbacks (e.g.,\n>     trace_printf(), etc, is implemented twice with a set of parallel\n>     wrappers).\n>\n>   - some constructs are just impossible and we've had to live without\n>     them (e.g., a cross between FLEX_ALLOC and xstrfmt)\n>\n> Since this feature is present in C99, we may be able to start counting\n> on it being available everywhere. Let's start with a weather balloon\n> patch to find out.\n>\n> This patch makes the absolute minimal change by always setting\n> HAVE_VARIADIC_MACROS. If somebody runs into a platform where it's a\n> problem, they can undo it by commenting out the define. Likewise, if we\n> have to revert this, it would be quite unlikely to cause conflicts.\n>\n> Once we feel comfortable that this is the right direction, then we can\n> start ripping out all the spots that actually look at the flag, and\n> removing the dead code.\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n> We've talked about this off and on for a few years. I don't have any\n> immediate plans for any features that need it, but let's get the ball\n> rolling.\n\nOK, so this is just callmine canary that can easily be undone when\nsomebody finds it problematic.  Let's give it enough time before we\nactually start removing the fallback code that are protected by\n\"#ifndef HAVE_VARIADIC_MACROS\" (they are quite well isolated---only\nin the usage and trace, which is pretty much expected as we'd be\nusing the feature for printf-like macros).\n\nThanks.\n\n>  git-compat-util.h | 7 +++++--\n>  1 file changed, 5 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index 104993b975..5d5e47fbe2 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -1176,9 +1176,12 @@ static inline int regexec_buf(const regex_t *preg, const char *buf, size_t size,\n>  #endif\n>  #endif\n>  \n> -#if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__C99_MACRO_WITH_VA_ARGS)\n> +/*\n> + * This is always defined as a first step towards making the use of variadic\n> + * macros unconditional. If it causes compilation problems on your platform,\n> + * please report it to the Git mailing list at git@vger.kernel.org.\n> + */\n>  #define HAVE_VARIADIC_MACROS 1\n> -#endif\n>  \n>  /* usage.c: only to be used for testing BUG() implementation (see test-tool) */\n>  extern int BUG_exit_code;\n"},{"id":"415556","messageId":"YBNu6mqzfhZFpHR/@camp.crustytoothpaste.net","threadId":"55064","inReplyTo":"YBJLgY+CWtS9TeVb@coredump.intra.peff.net","subject":"Re: [PATCH] git-compat-util: always enable variadic macros","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-01-29T02:11:54Z","receivedAt":"2021-01-29T02:13:32Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-01-28 at 05:28:33, Jeff King wrote:\n> We allow variadic macros in the code base, but only if there is fallback\n> code for platforms that lack it. This leads to some annoyances:\n> \n>   - the code is more complicated because of the fallbacks (e.g.,\n>     trace_printf(), etc, is implemented twice with a set of parallel\n>     wrappers).\n> \n>   - some constructs are just impossible and we've had to live without\n>     them (e.g., a cross between FLEX_ALLOC and xstrfmt)\n> \n> Since this feature is present in C99, we may be able to start counting\n> on it being available everywhere. Let's start with a weather balloon\n> patch to find out.\n> \n> This patch makes the absolute minimal change by always setting\n> HAVE_VARIADIC_MACROS. If somebody runs into a platform where it's a\n> problem, they can undo it by commenting out the define. Likewise, if we\n> have to revert this, it would be quite unlikely to cause conflicts.\n> \n> Once we feel comfortable that this is the right direction, then we can\n> start ripping out all the spots that actually look at the flag, and\n> removing the dead code.\n> \n> Signed-off-by: Jeff King <peff@peff.net>\n\nI'm in favor of this change.  In fact, as I've previously mentioned, I'm\nin favor of just requiring C99 support across the board.  It has been\nalmost 22 years since that standard came out, after all.\n\nApparently, even Visual Studio supports C11 and C17 now[0], so there's\nreally no reason not to switch.\n\n[0] https://docs.microsoft.com/en-us/cpp/overview/install-c17-support?view=msvc-160\n-- \nbrian m. carlson (he/him or they/them)\nHouston, Texas, US\n"}]}