This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Fwd: size_t is defined as an `int'.]


On Wed, Oct 18, 2000 at 01:19:42PM -0500, Joel Sherrill wrote:
> 
> This came across the RTEMS list.  I would like some opinions
> since it appears that the glibc on RedHat 6.2 also uses
> "int".  Solaris 2.x appears to use unsigned int.
> 
> Comments.

Yes, the ISO C standard requires that size_t be an unsigned type (though not
necessarily unsigned int, FYI the powerpc uses long unsigned int).  Old BSD
systems (like SunOS 4.1.4) used to define size_t in sys/types.h as 'int', which
I suspect is where RTEMS got it from.

> -- 
> Joel Sherrill, Ph.D.             Director of Research & Development
> joel@OARcorp.com                 On-Line Applications Research
> Ask me about RTEMS: a free RTOS  Huntsville AL 35805
>    Support Available             (256) 722-9985

> Message-ID: <39AFA2A9.7D95C6BB@cybertec.com.au>
> Date: Fri, 01 Sep 2000 23:35:53 +1100
> From: Chris Johns <cjohns@cybertec.com.au>
> Organization: Cybertec Pty Ltd
> X-Mailer: Mozilla 4.73 [en] (X11; I; Linux 2.2.12-20 i686)
> To: rtems <rtems-users@oarcorp.com>
> Subject: size_t is defined as an `int'.
> 
> Hi,
> 
> Someone on a project I am working on spotted `size_t' is an `int'. The
> ANSI standard states it should be an `unsigned int'. I found the
> definition in a RTEMS newlib file.
> 
>   newlib-1.8.2/newlib/libc/sys/rtems/sys/types.h :
>    typedef int size_t;            /* see C Standard XXX */ 
> 
> I found "N843, the Final Committee Draft" of the ANSI C standard at :
> 
>  http://www.lysator.liu.se/c/index.html
> 
> To quote the section "Common definitions <stddef.h>" :
> 
>  "  size_t
>    which is the unsigned integer type of the result of the sizeof
> operator;"
> 
> Should size_t be changed ?
> 
> -- 
>  Chris Johns, mailto:cjohns@cybertec.com.au mailto:ccj@acm.org


-- 
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]