Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Oct 1995 13:10:40 -0600 (MDT)
From:      Dave Andersen <angio@aros.net>
To:        wollman@lcs.mit.edu (Garrett A. Wollman)
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Help -- Stupid "C" question.
Message-ID:  <199510271910.NAA14179@terra.aros.net>
In-Reply-To: <9510271522.AA22958@halloran-eldar.lcs.mit.edu> from "Garrett A. Wollman" at Oct 27, 95 11:22:05 am

next in thread | previous in thread | raw e-mail | index | archive | help
Lo and behold, Garrett A. Wollman once said:
> 
> Hey, it's portable programming time!
> 
> Actually, let's be slightly more accurate here.
> 
> time(3) takes as its only argument a pointer to type `time_t'.  If
> that pointer is not null (NB: not `not NULL'), then it fills in that
> location with the current time.  In any case, it also returns a value
> of type `time_t'.  (Old systems spelled `time_t' l-o-n-g, but you
> should use `time_t' and define it yourself if the system doesn't.
> FreeBSD always has.)  Depending on your preferred style of
> programming, you might want to write either:
> 
> 	time_t thetime;
> 	time(&thetime);
> or
> 	time_t thetime;
> 	thetime = time((time_t *)0);
> 
> Note that the `(time_t *)' case is important for portable programs,
> unless you can guarantee that a complete prototype of the `time'
> function is in scope.  (I consider it to be good style anyway.)  The

    You are, of course, entirely correct here.  I seem to have been 
bitten by the laziness bug. :)  My use of the 'long' was somewhat 
egregious, however; it's the kind of thing that makes code break wildly 
after a long int isn't long enough to store the time since time began.

      -Dave Andersen

-- 
angio@aros.net                Complete virtual hosting and business-oriented
system administration         Internet services.  (WWW, FTP, email)
http://www.aros.net/          http://www.aros.net/about/virtual/
        "She totally confused all the passing piranhas"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510271910.NAA14179>