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

Kevin P. Fleming kpfleming at digium.com
Fri Nov 4 15:49:11 MST 2005


Luigi Rizzo wrote:

> 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

I don't think I like either of these options; rather, let's come up with 
some preprocessor magic to 'learn' what the correct format should be, 
and define a macro containing the proper printf format string 
(AST_TIME_T_FORMAT). Then:

   snprintf(buf, sizeof(buf), "This is the time " AST_TIME_T_FORMAT 
"\n", time());

would do the correct thing.

You mention that time_t is 'long' on FreeBSD 4.x; is that true even on 
64-bit architectures?



More information about the asterisk-dev mailing list