Mail Archives: djgpp-workers/2003/01/21/09:05:20
Hello.
Going back a bit here: the message quoted below is dated Tue, 19 Jun 2001
23:04:41 +0200 (MET DST) on my system.
Martin Str|mberg wrote:
>
> According to DJ Delorie:
> >
> > > Any particular reason for not having "#define __DJ_ssize_t
> > > typedef long int ssize_t"? Or even "long signed int ssize_t"?
> >
> > There is no reason for or against any change. Nobody is supposed to
> > know what those types are, so it shouldn't matter what they are. Is
> > there a specific reason for the change?
>
> I thought ssize_t was the signed couterpart of size_t. If so, they
> should be similarly defined. Like they are now, when I need to cast
> from size_t I currently use "(int)" because there isn't any similarity
> between size_t and ssize_t. If ssize_t == signed size_t, then using
> "(ssize_t)" would be more appropriate.
>
> Look at my signed/unsigned mail to follow soon.
Well, we still seem to have ssize_t defined as an int and size_t defined as a
long. I'm currently coding up support for the 'z' conversion qualifier for
printf. This specifies that the following integer is of size_t or some
equivalent sized thing. This is the kind of code that should work IMHO:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
int
main (void)
{
ssize_t foo = 5;
printf("%zd\n", foo);
return(EXIT_SUCCESS);
}
When I compile it, I get this warning:
gcc @../../../gcc.opt -I. -I- -I../../../../include -c foo.c
cc1.exe: warnings being treated as errors
foo.c: In function `main':
foo.c:17: warning: signed size_t format, ssize_t arg (arg 2)
make.exe: *** [foo.o] Error 1
If I change the program to define ssize_t like this:
typedef long int ssize_t;
instead of including <sys/types.h>, then I get no warning.
I haven't tried changing <sys/djtypes.h> to define ssize_t as a long. Has
anyone tried it?
Thanks, bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
- Raw text -