Article View: comp.std.c
Article #2157Re: Change to time() fn?
From: Rahul Dhesi
Date: Tue, 29 Sep 1992 22:21
Date: Tue, 29 Sep 1992 22:21
36 lines
1768 bytes
1768 bytes
In <704@mtndew.Tustin.CA.US> friedl@mtndew.Tustin.CA.US (Stephen
Friedl) writes:
>The recent spate of articles on the implementation of times encourages
>me to post a reminder to all UNIX folks -- do NOT use /long/ when you
>mean /time_t/.
The old portability versus standard-conformance conflict.
time_t is standard-conformant; so it will work on nearly 100% of
new systems, and on about 30% of old ones.
long is portable; so it will work on nearly 99.7% of new systems,
and on about 100% of old ones.
So: Be as standard-conformant as you can; be as portable if you wish;
but realize that it's very, very hard to be all of both.
A solution: A standardized type name should be accompanied by a
standardized #define. Then people like me, who want to be both
portable and standard-conformant, can do this:
/* portable *and* standard-conformant in a parallel universe */
#ifdef _HAVE_TIME_T
# define TIME_T time_t
#else
# define TIME_T long
#endif
Note that such accompanying defines are already needed to avoid
duplicate typedefs, when the same thing is defined in multiple standard
include files. So long as they are needed, it would be worth while (in
the next standard, ANSI C 1999 or so) to have official names for them.
--
Rahul Dhesi <dhesi@cirrus.com>
also: dhesi@rahul.net
Technical Details
Message-ID:
<1992Sep29.222157.23749@cirrus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!indetech!cirrus!dhesiReferences:
<1992Sep13.184530.27370@ima.isc.com> <1992Sep17.182536.17331@thinkage.on.ca> <704@mtndew.Tustin.CA.US>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!indetech!cirrus!dhesi From: dhesi@cirrus.com (Rahul Dhesi) Subject: Re: Change to time() fn? Message-ID: <1992Sep29.222157.23749@cirrus.com> Sender: news@cirrus.com Organization: Cirrus Logic Inc. References: <1992Sep13.184530.27370@ima.isc.com> <1992Sep17.182536.17331@thinkage.on.ca> <704@mtndew.Tustin.CA.US> Date: Tue, 29 Sep 1992 22:21:57 GMT Lines: 36