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'.]


"J. Johnston" wrote:
> 
> 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.
> >
> 
> size_t must be unsigned as defined in the ANSI, POSIX, and Single UNIX standards.  A signed version
> ssize_t is defined in POSIX and Single UNIX.
>
> The underlying definition of size_t is in stddef.h which is part of the compiler.
> A small test case on my Linux 6.2 using gcc version 2.95.2 gives the following in
> the -E output:
> 
> typedef unsigned int size_t;

When I tried this I get the same results on the native compiler and 
one of the cross rtems (powerpc).  I guess this report and (I know) my
analysis were based on grep'ing the include files.  There is an
incorrect definition of size_t in newlib/libc/sys/rtems/sys/types.h.
Based on this discussion, should that file simply include stddef.h and
eliminate some code?
 
> Everywhere I looked in glibc, it punts the underlying definition of size_t to stddef.h
> after defining __need_size_t.
> 
> Do you have an example of glibc defining size_t to signed?  By any chance is your compile
> setting one of the special defines used in stddef.h to override size_t (e.g. __SIZE_TYPE__)?
> 
> -- Jeff Johnston (Red Hat Inc)

-- 
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

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