Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site elsie.UUCP Path: utzoo!watmath!clyde!burl!ulysses!harpo!seismo!rlgvax!cvl!elsie!ado From: ado@elsie.UUCP Newsgroups: net.unix-wizards Subject: Re: 4.2BSD ctime() arguments Message-ID: <872@elsie.UUCP> Date: Mon, 16-Apr-84 11:15:07 EST Article-I.D.: elsie.872 Posted: Mon Apr 16 11:15:07 1984 Date-Received: Tue, 17-Apr-84 07:44:57 EST References: <398@noscvax.UUCP>, <3741@utzoo.UUCP> Organization: NIH-LEC, Bethesda, MD Lines: 48 Henry Spencer notes: . . .The argument to gmtime() should be of type "time_t", and ***ONLY*** time_t. Just exactly what kind of int time_t is, is something that is machine-dependent and system-dependent; you are not supposed to imbed such assumptions into your programs! The manual page is a bit out of date. The lint library is correct. The include file is machine-dependent and 4.2BSD-dependent. . .it *should* have been "typedef long time_t"! It makes no actual difference on the VAX, but it makes the portability situation a lot clearer. There are a *LOT* of Unix machines where time_t is not int. . . The "ctime" manual page on our 4.1 system has "7th Edition" in the lower-left-hand corner. I suspect that on "7th Edition" systems the way to call "ctime" is STILL with a "long *". I don't know if the "sys/types.h" file in which "time_t" is "typedef"d is even present on "7th edition" systems. Is there anyone out there who does? (And what's the situation on System V with respect to the "ctime" argument?) On our 4.1 system, the lint library (or the "ctime" source code, take your pick) is wrong. The lint library claims that "ctime" takes a "time_t *" as its argument, where "time_t" has been "typedef"d to be an "int". But "ctime.c" reads (in part): char * ctime(t) long *t; { . . . which says that "ctime" takes a "long *" as its argument. Maybe this discrepancy has been fixed in 4.2bsd. Then again, maybe it has been replaced with a new discrepancy. Can anyone running 4.2 shed light on this? The bottom lines: to keep "lint" happy and ensure portability, I'd do this: #ifdef vax #include time_t timearg; #else long timearg; #endif -- UNIX is an AT&T (or Bell Labs, or AT&T Bell Labs) trademark. (Can some AT&T mouthpiece post the preferred form for this note?) VAX is a Digital Equipment Corporation trademark. TIME is a Time/Life, Incorporated trademark. -- UUCP: decvax!harpo!seismo!rlgvax!cvl!elsie!ado DDD: (301) 496-5688