Xref: utzoo comp.unix.sysv386:8291 comp.lang.c:39463 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!sdd.hp.com!wuarchive!uunet!news.uu.net!mcsun!ukc!axion!delluk!holly!tim From: tim@dell.co.uk (Tim Wright) Newsgroups: comp.unix.sysv386,comp.lang.c Subject: Re: time(0L) - history of a misconception (was Re: SCO password generator) Message-ID: Date: 22 May 91 08:55:29 GMT References: <1991May14.040042.15199@jpradley.jpr.com> <588@sherpa.UUCP> <1141@mwtech.UUCP> <381@tmcsys.UUCP> Sender: usenet@delluk.uucp (Usenet posting login) Organization: Dell Computer Corp., Bracknell, UK Lines: 61 In <381@tmcsys.UUCP> lothar@tmcsys.UUCP (L. Hirschbiegel) writes: >In article <1141@mwtech.UUCP> martin@mwtech.UUCP (Martin Weitzel) writes: >>In article <588@sherpa.UUCP> rac@sherpa.UUCP (Roger Cornelius) writes: >>[...] >>> long seed = time(0L); >> ^^--------- wrong >> time((long *)0); >> ^^^^^^^^^--- right >> >You're a cousin of "lint", aren't you :-) ? >>Note that the argument to the time system call is a `long *', aka >>pointer to long. >Ever tried to RTFM for yourself? > NAME > time - get time > DESCRIPTION > The time system call returns the value of time in seconds > since 00:00:00 Greenwich Mean Time (GMT), January 1, 1970. > If tloc is non-zero, the return value is also stored in the > ^^^^^^^^^^^ > location to which tloc points. >If you still don't understand: I'll help you! >For this little test program: Yes but it's a pointer i.e. they are talking about a non-zero or non-null pointer. If the compiler allows prototypes, it can cast a 0 correctly. Without prototypes it cannot. >main() >{ >time(0L); >time((long *)0); >} >the assembler output from my C compiler is: ... irrelevant :-) >>Repeat after me: POINTER to long. >Repeat after me: IT DOESN'T MATTER :-) *WRONG* *WRONG* *WRONG*. Just because it doesn't happen to matter on *YOUR* machine with *YOUR* C compiler does not mean it does not matter. On a non-ansi compliant compiler on a '286 system it is possible to choose a memory model where sizeof(long) != sizeof(long *). In this case the code generated will be somewhat different :-) Tim -- Tim Wright, Dell Computer Corp., Bracknell | Domain: tim@dell.co.uk Berkshire, UK, RG12 1RW. Tel: +44-344-860456 | Uucp: ...!ukc!delluk!tim Smoke me a Kipper, I'll be back for breakfast - Red Dwarf