Article View: gnu.gcc.help
Article #52374Re: gcc & Ultrix "time.h"
From: Johan Vromans
Date: Wed, 21 Oct 1992 10:29
Date: Wed, 21 Oct 1992 10:29
81 lines
3903 bytes
3903 bytes
In article <BwFKGs.J1s@mtholyoke.edu> jbotz@mtholyoke.edu (Jurgen Botz) writes:
> I've been using gcc on DECstations for a couple of years now (always
> pretty much the latest version of gcc and Ultrix) and have
> consistently had problems compiling programs that use stuff declared
> in "time.h". I've always been able to fix it by making trivial
> changes to the source or Makefiles, but I still haven't figured out
> just exactly what is different between gcc and DEC cc that causes
> these problems to come up so consistently. DEC's header's are a maze
> of #ifdefs (because they're supposed to work with ANSI, non-ANSI, and
> POSIX sources, compilers, environments), and I figure that gcc is not
> defining something that DEC's MIPS cc is... but what is it?
Having struggled with this some time, I came to the following
solution.
In my gcc copy of time.h (/usr/local/lib/gcc-include/sys/time.h) I
have added another preprocessor conditional 'TIME_T_LONG'. When this
is defined, all time_t entities are treated as long. If a compilation
fails on type mismatch of time related functions, I add -DTIME_T_LONG
to the compiler flags and usually -- bingo!
It probably violates some standards, but it is a useful work-around.
These are the diffs (based on Ultrix 4.0):
*** /usr/include/sys/time.h Tue Oct 2 20:11:23 1990
--- /usr/local/lib/gcc-include/sys/time.h Wed Oct 21 11:27:33 1992
***************
*** 158,176 ****
#ifndef KERNEL
#ifdef __STDC__
/*
* prototypes
*/
extern char * asctime( struct tm *__tm );
extern clock_t clock( void );
! extern char * ctime( time_t *__clock );
! extern double difftime( time_t __time1, time_t __time0 );
! extern struct tm * gmtime( time_t *__clock );
! extern struct tm * localtime( time_t *__clock );
! extern time_t mktime( struct tm *__timeptr );
extern size_t strftime( char *__s, size_t __maxsize,
char *__format, struct tm *__tm );
! extern time_t time( time_t *__tloc );
#else
extern struct tm *gmtime(), *localtime();
--- 158,182 ----
#ifndef KERNEL
#ifdef __STDC__
+ #ifdef TIME_T_LONG
+ # define ___TIME_T long
+ #else
+ # define ___TIME_T time_t
+ #endif
+
/*
* prototypes
*/
extern char * asctime( struct tm *__tm );
extern clock_t clock( void );
! extern char * ctime( ___TIME_T *__clock );
! extern double difftime( ___TIME_T __time1, ___TIME_T __time0 );
! extern struct tm * gmtime( ___TIME_T *__clock );
! extern struct tm * localtime( ___TIME_T *__clock );
! extern ___TIME_T mktime( struct tm *__timeptr );
extern size_t strftime( char *__s, size_t __maxsize,
char *__format, struct tm *__tm );
! extern ___TIME_T time( ___TIME_T *__tloc );
#else
extern struct tm *gmtime(), *localtime();
--
Johan Vromans jv@mh.nl via internet backbones
Multihouse Automatisering bv uucp:..!{uunet,sun4nl}!mh.nl!jv
Doesburgweg 7, 2803 PL Gouda, The Netherlands phone/fax: +31 1820 62911/62500
------------------------ "Arms are made for hugging" -------------------------
Technical Details
Message-ID:
<BwGvsH.7oy@pronto.mh.nl>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!mhres!pronto!newsReferences:
<BwFKGs.J1s@mtholyoke.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,e300e56b412821a X-Google-Attributes: gid11318c,public X-Google-Thread: 10b612,e300e56b412821a X-Google-Attributes: gid10b612,public X-Google-ArrivalTime: 1992-10-21 00:23:08 PST Newsgroups: gnu.gcc.help,comp.unix.ultrix Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!mhres!pronto!news From: jv@mh.nl (Johan Vromans) Subject: Re: gcc & Ultrix "time.h" In-Reply-To: jbotz@mtholyoke.edu's message of 20 Oct 92 17:26:52 GMT Message-ID: <BwGvsH.7oy@pronto.mh.nl> X-Md4-Signature: f3c1da95eb90d214cc7a3a1531a942b7 Sender: news@pronto.mh.nl (USEnet News System) Nntp-Posting-Host: pronto:(jv) Organization: Multihouse Automation, the Netherlands References: <BwFKGs.J1s@mtholyoke.edu> Date: Wed, 21 Oct 1992 10:29:04 GMT Lines: 81