1
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,

ant2009
  • 27,094
  • 154
  • 411
  • 609

2 Answers2

3

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.

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
  • I did cast it at first. But I was wondering if there was a format specifier I could use instead. Thanks. – ant2009 Nov 01 '11 at 07:51
2

Try:

printf("The current time: %" APR_TIME_T_FMT "[us]\n", apr_time_now());

Tutorial.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242