🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2158

Re: Change to time() fn?

#2158
From: Norman Diamond
Date: Wed, 30 Sep 1992 01:10
47 lines
2631 bytes
In article <1992Sep29.222157.23749@cirrus.com> dhesi@cirrus.com (Rahul Dhesi) writes:
>long is portable;  so it will work on nearly 99.7% of new systems,
>and on about 100% of old ones.

Maybe somewhat less than 99.7% of new systems, as new systems move towards
encoding the bits of a double in a funny manner.

>A solution:  A standardized type name should be accompanied by a
>standardized #define.

Or a non-standardized #define or typedef or any other implementation solution
to yield standardized BEHAVIOR.

>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

That is neither portable nor standard-conformant because _HAVE_TIME_T is in
the implementation's namespace, and the implementation can choose to define
it or not define it arbitrarily, just to mess you up if it wishes.

However, #ifdef and a related definition in the user's namespace are indeed
a reasonable solution (for contending with the mess that it has to contend
with).  Here's something a bit simpler:

  #ifndef HAVE_TIME_T
  typedef long time_t;
  #endif

>Note that such accompanying defines are already needed to avoid
>duplicate typedefs, when the same thing is defined in multiple standard
>include files.

Huh?  If an implementation chooses to define __TIME__ for that purpose,
instead of the name you liked, where does that leave you?
If an implementation has the standard headers in RAM while the compiler
is running, and has its own array of booleans to remind it of what it
has already included, then it would not have to define anything at all.
--
Norman Diamond       diamond@jit081.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
"Yeah -- bad wiring.  That was probably it.  Very bad."
Technical Details
Message-ID: <1992Sep30.011004.1807@nntpd.lkg.dec.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!noc.near.net!hri.com!spool.mu.edu!decwrl!deccrl!news.crl.dec.com!news!nntpd.lkg.dec.com!jit345.bad.jit.dec.com!diamond
References: <1992Sep13.184530.27370@ima.isc.com> <1992Sep17.182536.17331@thinkage.on.ca> <704@mtndew.Tustin.CA.US> <1992Sep29.222157.23749@cirrus.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!noc.near.net!hri.com!spool.mu.edu!decwrl!deccrl!news.crl.dec.com!news!nntpd.lkg.dec.com!jit345.bad.jit.dec.com!diamond
From: diamond@jit345.bad.jit.dec.com (Norman Diamond)
Newsgroups: comp.std.c
Subject: Re: Change to time() fn?
Message-ID: <1992Sep30.011004.1807@nntpd.lkg.dec.com>
Date: 30 Sep 92 01:10:04 GMT
References: <1992Sep13.184530.27370@ima.isc.com> <1992Sep17.182536.17331@thinkage.on.ca> <704@mtndew.Tustin.CA.US> <1992Sep29.222157.23749@cirrus.com>
Sender: usenet@nntpd.lkg.dec.com (USENET News System)
Reply-To: diamond@jit.dec.com (Norman Diamond)
Organization: Digital Equipment Corporation Japan , Tokyo
Lines: 47