From owner-freebsd-stable Sat Jun 2 17:33:31 2001 Delivered-To: freebsd-stable@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 1B05637B424 for ; Sat, 2 Jun 2001 17:33:28 -0700 (PDT) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.9.3/8.9.3) id UAA57864; Sat, 2 Jun 2001 20:33:08 -0400 (EDT) (envelope-from wollman) Date: Sat, 2 Jun 2001 20:33:08 -0400 (EDT) From: Garrett Wollman Message-Id: <200106030033.UAA57864@khavrinen.lcs.mit.edu> To: Yoshihiro.Koya@math.yokohama-cu.ac.jp Subject: Re: time_t definition is worng X-Newsgroups: mit.lcs.mail.freebsd-stable In-Reply-To: <20010603012933K.koya@pluto.math.yokohama-cu.ac.jp> References: <20010602085237.A73968@dragon.nuxi.com> <20010603010518C.koya@pluto.math.yokohama-cu.ac.jp> <20010602091643.C73968@dragon.nuxi.com> Organization: MIT Laboratory for Computer Science Cc: stable@freebsd.org Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In article <20010603012933K.koya@pluto.math.yokohama-cu.ac.jp> you write: >The pw->pw_chage and pw->pw_passwd are of time_t. But, in the above, >%ld is used for them. This is a general problem; there is no portable way to print a time_t that does not include the following steps: 1) Determine whether time_t is integral, floating-point, or (new in C99) complex. 2) If time_t is integral, determine whether it is signed or unsigned. 3) If the compilation environment is not C99, and time_t is integral, cast to (appropriately signed) long and print with %ld or %lu as appropriate. If the compilation environment is (close enough to) C99, case to (appropriately signed) intmax_t and print with %jd or %ju as appropriate. If time_t is floating-point, cast to long double and print with %Lf. If time_t is complex, you have a lot more serious problems to deal with. There is a simple way around this, for POSIX systems only: use strftime() with the %s format. -GAWollman -- Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same wollman@lcs.mit.edu | O Siem / The fires of freedom Opinions not those of| Dance in the burning flame MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message