Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: printf and time_t
Date: Tue, 03 Feb 2026 22:03:05 -0800
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <86a4xphwpy.fsf@linuxsc.com>
References: <10jfol6$2u6r8$1@news.xmission.com> <10jfs23$2liif$1@dont-email.me> <20260105105138.00005f0a@yahoo.com> <10jgbp7$2vdjt$1@news.xmission.com> <10jgdu9$2t8dh$1@nntp.eternal-september.org> <10jhkso$3c9r2$3@nntp.eternal-september.org> <20260106112938.00004446@yahoo.com> <10jj9st$3jbe4$2@dont-email.me> <20260106200522.000015ea@yahoo.com> <87h5sy2rlb.fsf@example.invalid> <20260107140134.000075f1@yahoo.com> <87v7hdhaju.fsf@example.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Wed, 04 Feb 2026 06:03:12 +0000 (UTC)
Injection-Info: dont-email.me; posting-host="30e2bd46efc1ceede85686db5fb0dc7e"; logging-data="2214876"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180HGuXK70S8iQXzf48DnkHCg8JQl7qQ5Y="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:OChpbS+IIIJ1DITAGQrooLgNFq0= sha1:fRbY//BlZroWgXLfcdUYtFpWStY=
Xref: csiph.com comp.lang.c:396586
Keith Thompson writes:
> Michael S writes:
>
>> On Tue, 06 Jan 2026 16:29:04 -0800
>> Keith Thompson wrote:
>>
>>> Michael S writes:
>>>
>>>> On Tue, 6 Jan 2026 10:31:41 -0500
>>>> James Kuyper wrote:
>>>>
>>>>> On 2026-01-06 04:29, Michael S wrote:
>>>>>
>>>>>> On Tue, 6 Jan 2026 00:27:04 -0000 (UTC)
>>>>>> Lawrence D?Oliveiro wrote:
>>>>>
>>>>> ...
>>>>>
>>>>>>> Section 7.8 of the C spec defines macros you can use so you
>>>>>>> don?t have to hard-code assumptions about the lengths of
>>>>>>> integers in printf-format strings.
>>>>>>
>>>>>> Did you ever try to use them? They look ugly.
>>>>>
>>>>> Which is more important, correctness or beauty?
>>>>
>>>> It depends.
>>>>
>>>> When I know for sure that incorrectness has no consequences, like
>>>> in case of using %u to print 'unsigned long' on target with 32-bit
>>>> longs, or like using %llu to print 'unsigned long' on target with
>>>> 64-bit longs, then beauty wins. Easily.
>>>
>>> Seriously?
>>>
>>> An example:
>>>
>>> unsigned long n = 42;
>>> printf("%u\n", n); // incorrect
>>> printf("%lu\n", n); // correct
>>>
>>> Are you really saying that the second version is so much uglier
>>> than the first that you'd rather write incorrect code?
>>
>> No, I don't think that it is much uglier. At worst, I think that
>> correct version is tiny bit uglier. Not enough for beauty to win
>> over "correctness", even when correctness is non-consequential.
>>
>> I hoped that you followed the sub-thread from the beginning and
>> did not lost the context yet.
>
> The context to which I replied was you favoring beauty over
> correctness and using "%u" to print an unsigned long value as
> an example.
>
> I find it difficult to express how strongly I disagree.
I think it would be more helpful to readers if you would put your
efforts more into understanding and explaining why you disagree
than into expressing how strongly you disagree.