Sender: rich AT phekda DOT freeserve DOT co DOT uk Message-ID: <3E2D52C7.70E1DDEB@phekda.freeserve.co.uk> Date: Tue, 21 Jan 2003 14:01:43 +0000 From: Richard Dawe X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586) X-Accept-Language: de,fr MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Re: size_t and ssize_t References: <200106192104 DOT XAA18859 AT father DOT ludd DOT luth DOT se> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com 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 #include #include 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 , then I get no warning. I haven't tried changing to define ssize_t as a long. Has anyone tried it? Thanks, bye, Rich =] -- Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]