[Asterisk-Dev] Re: ast_localtime() weird interface.
Tony Mountifield
tony at softins.clara.co.uk
Wed Oct 12 00:15:37 MST 2005
In article <20051011233741.B19609 at xorpc.icir.org>,
Luigi Rizzo <rizzo at icir.org> wrote:
> hi,
> i am trying to compile asterisk-current with -Werror to clean up
> compile errors, and amomg other things i hit a number of inconsistencies
> on the first argument of ast_localtime() (this on FreeBSD-6, but
> the problem may exist elsewhere depending on how time_t is defined).
>
> Looking it up, i notice that ast_localtime has this interface:
>
> struct tm *
> ast_localtime(timep, p_tm, zone)
> const time_t * const timep;
> struct tm *p_tm;
> const char * const zone;
>
> and i wonder why the first argument is passed by name rather than
> by value.
> I see no reason for that,
I would think the reason is that it is designed to be as much as
possible a drop-in replacement for the standard localtime(3) or
localtime_r(3) functions, and they both take a pointer to a time_t as
their first argument:
struct tm *localtime(const time_t *timep);
struct tm *localtime_r(const time_t *timep, struct tm *result);
> and i'd like to change it, so that it is much easier to deal with the
> different definitions of time_t on the various platforms.
Since everyone who is familiar with the localtime functions would be
used to the existing case, I think such a change would be less
desirable.
What kind of problems are you encountering in dealing with the different
definitions of time_t?
Cheers
Tony
--
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org
More information about the asterisk-dev
mailing list