Search code examples
capr

format specifier for apr apr_time_h


gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
    Apache protable runtime 1.4
    c89 and compiling in -m32 mode

Code:

apr_time_t time_msecs = 0;
time_msecs = apr_time_as_msec(apr_time_now());
printf("Time in msecs [ %lu ]\n", time_msecs);

I get the following warning:

format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘apr_time_t’ [-Wformat]

Apart from casting. What is the correct format specifier for this type (apr_time_t)?

Many thanks for any suggestions,


Solution

  • APR contains a macro called APR_TIME_T_FMT which might do what you want.

    When building your format string, you use it like that (assuming it works like the stdint macros): printf("time: %" APR_TIME_T_FMT, value);
    You could also simply cast the value to the appropriate type.