我编写了一个非常简单的printf uint 64测试代码:
#include <inttypes.h>
#include <stdio.h>
int main()
{
uint64_t ui64 = 90;
printf("test uint64_t : %" PRIu64 "\n", ui64);
return 0;
}
我使用ubuntu11.10(64位)和gcc版本4.6.1编译它,但失败了:
main.cpp: In function ‘int main()’:
main.cpp:9:30: error: expected ‘)’ before ‘PRIu64’
main.cpp:9:47: warning: spurious trailing ‘%’ in format [-Wformat]
发布于 2018-03-23 19:23:55
ISO C99标准规定,只有在显式请求时才必须定义这些宏。
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
... now PRIu64 will work
发布于 2018-03-23 20:38:29
在CentOS5.x下编译memcached时,我遇到了同样的问题。
解决方案是至少将gcc和g++升级到4.4版本。
https://stackoverflow.com/questions/-100003682
复制相似问题