delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/18/06:11:18

From: "A. Sinan Unur" <sinan AT unur DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: C++, complex, etc
Date: Thu, 18 May 2000 03:29:48 -0400
Organization: http://unur.com/
Lines: 38
Sender: verified_for_usenet AT cornell DOT edu (asu1 on ip100.ithaca.ny.pub-ip.psi.net)
Message-ID: <8g0688$cdm$1@news01.cit.cornell.edu>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000517145742 DOT 626A-100000 AT is> <3922DA9E DOT 8DF00783 AT mtu-net DOT ru> <392311DE DOT 3700368D AT bigfoot DOT com> <39236A55 DOT 78749ABD AT mtu-net DOT ru>
NNTP-Posting-Host: ip100.ithaca.ny.pub-ip.psi.net
X-Trace: news01.cit.cornell.edu 958635080 12726 38.10.16.100 (18 May 2000 07:31:20 GMT)
X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu
NNTP-Posting-Date: 18 May 2000 07:31:20 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> > > Eli Zaretskii wrote:
> > > > You need it for portability.
> > > >
> > > > size_t is not equal to int.  Its precise definition depends on
> > > > the implementation.
...
> > > > You seem to be missing the point that you shouldn't rely on
> > > > size_t and int being the same size (also: size_t is unsigned,
> > > > ssize_t is signed).


"Alexei A. Frounze" <alex DOT fru AT mtu-net DOT ru> wrote in message
news:39236A55 DOT 78749ABD AT mtu-net DOT ru...

> I've never said I _rely_. I don't use size_t in my sources. Only
> standard types: char, short, int, long int, long long,... ;)

i am sorry but this statement makes no sense. size_t is no less standard
than int, but afaik long long is not in the standard at all.

eli's warning is extremely appropriate: size_t has a well defined meaning
that "it is the safest type that can represent the size of the largest data
object you can create" (P.J. Plauger's "The Standard C Library", p.219.)

for example, the following code is not safe

int main(int argc, char *argv[]) {
  unsigned len  = strlen(argv[0]);
}

because unsigned int is not guaranteed to be able to hold a size_t even
though it may seem to work for now.

--
mailto:Sinan_Unur AT mail DOT com
http://unur.com/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019