Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!sun!guy From: guy@sun.UUCP Newsgroups: net.lang.c Subject: Re: time(2 or 3) Message-ID: <4270@sun.uucp> Date: Thu, 19-Jun-86 14:45:06 EDT Article-I.D.: sun.4270 Posted: Thu Jun 19 14:45:06 1986 Date-Received: Sat, 21-Jun-86 12:20:26 EDT References: <337@lll-lcc.UUcp> <798@isis.UUCP> <2021@umcp-cs.UUCP> <840@isis.UUCP> Organization: Sun Microsystems, Inc. Lines: 36 > In article <2021@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) shows > >> somevar1 = time(0); > > > > Specifically, time() is a function returning long, taking > >a _pointer_ to long...; > >Change to: > > ... > > somevar1 = time((long *) 0); > > Of course Chris is right; I just ':r some_prog_of_mine' that _worked_(!)... More precisely, that happened to work on the machine you built it on. "This program works" (which almost always means "this program works on some subset of the machines on which it could conceivably work) is not equivalent to "this program is correct". There are *lots* of machines on which "somevar = time(0);" will *not* work, and such machines have perfectly legal C implementations. Those of you on VAXes, Suns, Pyramids, 3Bs, etc. may not think it matters to write type-correct code, since you can get away with not doing so; however, you'll regret it the day somebody wants your program ported to, say, a PC using the large memory model, or a small 68000-based machine using 16-bit "int"s. Chris' complaint was perfectly legitimate, as would "lint"s complaint about the same statement (you *do* run "lint", of course). > Of course, it helps my case a bit that _my_ manual (albiet an old V7) > has the following in time(2): (honest) > > long time(0) <<<< this is what I recommended. Yes, the V7 manual is old, and you could get away with that sort of thing on the PDP-11 where V7 was first done. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)