Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: fread a file of unknown size |
| Date | 2015-03-09 20:07 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <mdkuhs$ud$1@speranza.aioe.org> (permalink) |
| References | (2 earlier) <mdiq3n$537$1@dont-email.me> <mdispa$ah5$1@speranza.aioe.org> <87twxu2pew.fsf@kst-u.example.com> <mdklm3$9dl$1@speranza.aioe.org> <87pp8i2hh0.fsf@kst-u.example.com> |
Keith Thompson <kst-u@mib.org> wrote: (snip, I wrote) >> The biggest problem I remember with gnu utilities is that they would >> use 0 as an argument to a function expecting (char *). When I complained >> to the gnu people, they had some comment about systems having different >> sized (int) and (char*) not being supported. > I don't suppose you have an example? > If there's a visible prototype, passing 0 to a non-variadic function > expecting a char* is not a problem. It will be implicitly converted to > char*, and converting a constant 0 to a pointer type yields a null > pointer. (Personally I'd use NULL or (char*)NULL just for the sake of > clarity.) That was in 1990. I was running MSC 6.0 (the first with OS/2 support) and large mode, so pointers were segment selector/offset in 32 bits, and int at 16 bits. > Passing 0 to a function expecting a char* either when there's no visible > prototype, or when it corresponds to the ", ..." in a variadic function, > does have undefined behavior. It can break if char* and int are of > different sizes, if a null pointer is not represented as all-bits-zero, > if int and char* are passed as arguments using different mechanisms, or > for any other conceivable reason. Microsoft had ANSI C support around 1989, but I don't know how fast people went back and added the prototypes. I do know that it wouldn't run until I put in (char*)0 for the 0 in the right places. -- glen
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
fread a file of unknown size ruben safir <ruben@mrbrklyn.com> - 2015-03-08 14:47 -0400
Re: fread a file of unknown size Richard Heathfield <rjh@cpax.org.uk> - 2015-03-08 18:59 +0000
Re: fread a file of unknown size James Kuyper <jameskuyper@verizon.net> - 2015-03-08 18:21 -0400
Re: fread a file of unknown size Keith Thompson <kst-u@mib.org> - 2015-03-08 18:43 -0700
Re: fread a file of unknown size fmassei@gmail.com - 2015-03-08 15:41 -0700
Re: fread a file of unknown size raltbos@xs4all.nl (Richard Bos) - 2015-03-10 16:04 +0000
Re: fread a file of unknown size Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-03-08 18:44 -0400
Re: fread a file of unknown size jacob navia <jacob@spamsink.net> - 2015-03-08 20:32 +0100
Re: fread a file of unknown size Keith Thompson <kst-u@mib.org> - 2015-03-08 12:48 -0700
Re: fread a file of unknown size glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-03-08 23:39 +0000
Re: fread a file of unknown size James Kuyper <jameskuyper@verizon.net> - 2015-03-08 20:40 -0400
Re: fread a file of unknown size glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-03-09 01:24 +0000
Re: fread a file of unknown size Keith Thompson <kst-u@mib.org> - 2015-03-09 07:53 -0700
Re: fread a file of unknown size glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-03-09 17:36 +0000
Re: fread a file of unknown size Keith Thompson <kst-u@mib.org> - 2015-03-09 10:44 -0700
Re: fread a file of unknown size glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-03-09 20:07 +0000
csiph-web