2011-11-01 69 views
1
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 
    Apache protable runtime 1.4 
    c89 and compiling in -m32 mode 

代碼:格式說明符四月apr_time_h

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

我得到以下警告:

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

分開。什麼是這種類型的正確格式說明符(apr_time_t)?

非常感謝您的任何建議,

回答

2

APR包含一個名爲APR_TIME_T_FMT的宏,它可以做你想做的事情。

當構建格式字符串,你使用它一樣,(假設它的工作方式類似於stdint宏):printf("time: %" APR_TIME_T_FMT, value);
你也只是值轉換爲適當的類型。

+0

我一開始就投了。但我想知道是否有一個格式說明符可以用來代替。謝謝。 – ant2009

-1

如果打開使用

男子3中的printf手冊頁的printf

和閱讀printf格式不會找到apr_time_t類型明確地什麼。

+0

這可以幫助他究竟如何? – ThiefMaster

+0

呵呵。他是新的。 – trojanfoe

2

嘗試:

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

Tutorial