bug-gnulib
[Top][All Lists]
Advanced

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

Re: size_max


From: Simon Josefsson
Subject: Re: size_max
Date: Sat, 25 Jun 2005 10:35:53 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Paul Eggert <address@hidden> writes:

>> In this case, I think naming me and Bruno as maintainer would be the
>> right thing.  Ok?
>
> It's fine with me, though I'd like to hear Bruno's opinion.

Yup, I'll wait for Bruno's response.

>> Should we start replacing
>>
>> /* Get SIZE_MAX.  */
>> #include <limits.h>
>> #if HAVE_STDINT_H
>> # include <stdint.h>
>> #endif
>>
>> and/or
>>
>> #ifndef SIZE_MAX
>> # define SIZE_MAX ((size_t) -1)
>> #endif
>>
>> with
>>
>> /* Get SIZE_MAX.  */
>> #include "size_max.h"
>
> I don't see a need for it, no.  (size_t) -1 works just fine, unless
> you need SIZE_MAX in #if lines.

Right.

>> Should size_max.h, as a safety precaution, read:
>> ...
>> # ifndef SIZE_MAX
>> #  define SIZE_MAX ((size_t) -1)
>> # endif
>
> No, because the main point of size_max.h (from my point of view,
> anyway) is to define a SIZE_MAX value that can be used in #if lines.
>
> Come to think of it, if your uses of SIZE_MAX are not in #if lines,
> why don't you just write
>
> #ifndef SIZE_MAX
> # define SIZE_MAX ((size_t) -1)
> #endif
>
> after all your system includes?  That is, do you really need a
> size_max module?  It seems like a lot of work to reduce three
> easily-understood lines to one.

Perhaps you are right...

Going over my uses of SIZE_MAX, none were in #if's.

I suppose I just found that idiom repeated in many places and found it
ugly.  I wanted to hide it away inside gnulib, and then assume I can
use SIZE_MAX directly in my code.

I guess, from my point of view, then, the point of size_max.h is
actually to define SIZE_MAX for any use, so I can avoid the '#ifndef
SIZE_MAX' idiom inside my source code.  I guess, then, I would
actually want to have the above safety-precaution present.

Not sure if avoiding that idiom is motivation enough for this
module...




reply via email to

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