[Asterisk-Dev] other -Werror issues - time_t printf format...

Luigi Rizzo rizzo at icir.org
Fri Nov 4 15:18:01 MST 2005


so now i am hitting another batch of -Werror related problems,
because in some places (res_features.c chan_iax2.c chan_sip.c
and maybe 1-2 more places) printf uses a %ld format for time_t
(and in some other places it uses %d).

On FreeBSD 6.x, time_t is __int32_t; on FreeBSD 4.x time_t is long.
In both cases the size is 32 bit, but the compiler is not
smart enough to understand that they are the same size and
thus %ld and %d are perfectly equivalent -- or, seen from another
perspective, the compiler is smart enough to understand that this
cannot be generalized and thus it compilains.

Whatever explaination we chose what would be the preferred fix ?
1. cast the operand to int and always use %d
2. cast the operand to long and always use %ld

they look equivalent to me.
ideally we would use a printf format that says 'this is a 32-bit
integer' but i don't think we do have one, am i mistaken ?

	cheers
	luigi



More information about the asterisk-dev mailing list