time(0L) - history of a misconception (was Re: SCO password generator)

Ian Collier imc at prg.ox.ac.uk
Thu May 23 20:45:58 AEST 1991


In article <381 at tmcsys.UUCP>, lh at aega84.UUCP (L. Hirschbiegel) wrote:
[about the argument of time()]
>	  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.

Obviously the writers of your manual don't know the difference between a
long and a pointer, then. Ours seems to have it about right...

SYNOPSIS
...
     time_t time(tloc)
     time_t *tloc;

DESCRIPTION
     time() returns the time since 00:00:00 GMT,  Jan.  1,  1970,
     measured in seconds.

     If tloc is non-NULL, the return value is also stored in  the
                    ^^^^
     location to which tloc points.

>For this little test program:
...
>the assembler output from my C compiler is:
...

All that means is that your computer represents a NULL pointer by zero
(also evident from your manual page). So for time(0L) it pushes a long
zero, and for time((long *)0) it pushes a null pointer, which is just
a long zero. That will happen on most computers, but not all. (As
someone has pointed out, however, if a prototype for time() is in scope
then a zero will be converted into a null pointer, probably without a
warning message).

Ian Collier
Ian.Collier at prg.ox.ac.uk | imc at ecs.ox.ac.uk



More information about the Comp.lang.c mailing list