今天用到一個read去讀取eventfd,結果想看看內容,用__android_log_print要顯示出內容,發現內容值的型態是uint64_t,編譯出現了這樣的告警: 

warning: format '%lld' expects argument of type 'long long int', but argument 5 has type 'uint64_t {aka long unsigned int}' [-Wformat=]
 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)

其實編譯是有成功的,但是越少告警程式越不容易有問題,找了一下google大神,有人講了以下解法:

#define __STDC_FORMAT_MACROS
#include <inttypes.h>

uint64_t count;
printf("%"PRIu64"\n", count);

以上是printf的用法,在NDK下自己改寫成需要的__android_log_print寫法編譯就會沒有告警了。

arrow
arrow

    大衛的記事 發表在 痞客邦 留言(0) 人氣()