RE: cb/pedantic-build-for-developers, POSIX-but-not-C99 and -Wno-pedantic-ms-format
- From
Randall S. Becker <rsbecker@nexbridge.com>
- Date
- Sep 22, 2021, 17:22 UTC
- Message-ID
- <02c701d7afd6$6f0a7f20$4d1f7d60$@nexbridge.com>
- In-Reply-To
- <xmqqilys8u74.fsf@gitster.g>
On September 22, 2021 12:13 PM, Junio C Hamano:
Show 23 quoted lines
>Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> I.e. complaining about "%m$" instead of "%" in printf formats, it's
>> easy enough to fix in my case, it's just something I used to
>> de-duplicate a rather complex format, this makes it C(89|99)-compliant:
>>
>> - strbuf_addf(&fmt, "%%s%%s%%s-%%0%1$lud.%%0%1$lud-%%s-%%s-%%s",
>> - (unsigned long)tmp.len);
>> + strbuf_addf(&fmt, "%%s%%s%%s-%%0%lud.%%0%lud-%%s-%%s-%%s",
>> + (unsigned long)tmp.len, (unsigned long)tmp.len);
>>
>> But in general, do we view -pedantic as an implicit endorsement that
>> we should be using less POSIX and more standard C than we otherwise would?
>>
>> I may be wrong, but I believe that construct is widely portable, we
>> don't use it in the main source, but in the po/ files (so anything
>> that uses git + gettext tests for this already):
>
>Reordering (_("%s %s"), a, b) to ("%2$s %1$s", a, b) is essential to make po/ work.
>
>While I do not think of a reason why it should not work, I am not sure duplicating (%1$s %1$s", a) falls into the same category.
>
>Any solution that makes the per-cent ridden format string is betterPositional parameters do not work on all POSIX platforms. Please do not do this. NonStop will be locked out of future git releases.
Sincerely, Randall