[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problems using localtime and gettimeofday
> From: firstname.lastname@example.org
> Date: Mon, 2 Jul 2001 15:34:32 -0600
Thank you for your precise report.
> The functions gettimeofday and localtime are , I believe, standard Linux
The function gettimeofday is deprecated, and in recent versions
of glibc, "struct timezone" is only available without "-ansi" or
when compiling with "-D_BSD_SOURCE" or "-D_GNU_SOURCE" (only a
NULL argument is valid otherwise).
> These functions worked using cris-1.11, linux-2.4.3, and
Different library, no surprise...
> Howver, they do not work using cris-1.13, linux-2.4.5, and
It's because of the "-ansi" option. Lose it, or add
"-D_BSD_SOURCE" or "-D_GNU_SOURCE". That lets your example
compile and run for me.
> I am attaching a timetest.tgz which demonstrates this problem. To access
> the files please do tar -zxvf timetest.tgz in a directory of your choosing.
> The source file is timetest.cc and the makefile is makefile.timetest.
> To see my problem:
> make -f makefile.timetest clean
> make -f makefile.timetest cris-axis-linux-gnu
> make -f makefile.timetest
> You will can compile errors.
It compiles and seems to run correctly for me when I, for
example, remove "-ansi" or add "-D_GNU_SOURCE".
> It will compile and run under Linux as follows:
What version of glibc is this; what distribution? My
Debian-potato-based system seems to have an old enough glibc,
though it says in gettimeofday(2): "The use of the timezone
struct is obsolete".