bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printf functions without INT_MAX limitation


From: Paul Eggert
Subject: Re: printf functions without INT_MAX limitation
Date: Mon, 22 Apr 2024 00:27:47 -0700
User-agent: Mozilla Thunderbird

On 2024-04-21 14:36, Bruno Haible wrote:

But direct use of off_t has two problems:
   - off_t is not defined by ISO C; thus it's an odd return type for things
     like zsprintf.

I was thinking that zsprintf should return ptrdiff_t and zprintf would return off_t. off_t is defined by POSIX <stdio.h>, so it's reasonable for zprintf to use it.


   - off_t changes depending on whether gl_LARGEFILE is in use or not;
     thus it's a bad idea to use it in the API of any shared library or
     (more generally) any independently-built component.

That ship sailed long ago, I'm afraid. That is, any API depending on I/O sizes must deal with this problem anyway, so there's nothing new here. (Also, the problem will go away soon enough anyway, as 32-bit off_t systems will likely die out by 2038 due to time_t issues of all things....)


I would prefer to solve this dilemma by defining a new type, say 'zoff_t',
that is required to be
   - at least as wide as off_t, and
   - at least as wide as ptrditt_t.

That should also work. Not sure whether it's better than using off_t for I/O and ptrdiff_t for main memory, though. Both approaches have pros and cons. An advantage of the off_t/ptrdiff_t approach is that it does not introduce a new type with all the confusion that would bring (there's a reason regoff_t has been so unpopular - even glibc doesn't implement it properly if memory serves...).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]