[Top][All Lists]

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

[Bug-gnulib] Re: xsize.h needs SIZE_MAX defined on Windows

From: Derek Robert Price
Subject: [Bug-gnulib] Re: xsize.h needs SIZE_MAX defined on Windows
Date: Sun, 07 Mar 2004 21:14:52 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1

Hash: SHA1

Hey all,

A quick addendum:

Mark D. Baushke from the CVS development team suggested that ~0 might be
a better value than -1 as it is more obviously positive.  He also
suggested that it wouldn't require the typecast, but I believe this
would not be the case, as I think ((size_t) ~0) and, say, ((long long)
~0) may not be the same number and allowing the compiler to pick how
many bytes to shove ~0 into based on the context of each use of SIZE_MAX
is almost certainly wrong here.

I can see the desirability of ((size_t) ~0) for simple sake of looking
more obviously positive than ((size_t) -1), however.


Derek Robert Price wrote:

>Hey all, here's a patch for lib/xsize.h: Basically, a default value for
>SIZE_MAX needs to be provided under Windows.  I did the same thing it
>looks like Paul did in lib/quotearg.c and defined it to ((size_t) -1)
>when no value has been found in the includes.
>Index: lib/xsize.h
>RCS file: /cvs/ccvs/lib/xsize.h,v
>retrieving revision 1.1
>diff -u -p -r1.1 xsize.h
>--- lib/xsize.h 15 Feb 2004 22:55:53 -0000 1.1
>+++ lib/xsize.h 7 Mar 2004 22:29:44 -0000
>@@ -28,6 +28,11 @@
># include <stdint.h>
>+/* Windows does not supply a definition for SIZE_MAX. */
>+#ifndef SIZE_MAX
>+# define SIZE_MAX ((size_t) -1)
>/* The size of memory objects is often computed through expressions of
>type size_t. Example:
>void* p = malloc (header_size + n * element_size).

- --

Email: address@hidden

Get CVS support at <http://ximbiot.com>!
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Netscape - http://enigmail.mozdev.org


reply via email to

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