如何给printf uint64_t中? [英] how to printf uint64_t?
本文介绍了如何给printf uint64_t中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写的printf uint64_t中的一个非常简单的测试code:
的#include< inttypes.h>
#包括LT&;&stdio.h中GT;诠释的main()
{
uint64_t中ui64 = 90;
的printf(测试uint64_t中:%PRIu64\\ n,ui64);
返回0;
}
我使用Ubuntu 11.10(64位)和gcc版本4.6.1编译它,但失败了:
main.cpp中:在函数'廉政的main():
main.cpp中:9:30:错误:'PRIu64之前的预期)
main.cpp中:9:47:警告:虚假尾随'%'格式[-Wformat]
解决方案
ISO C99标准规定,如果明确要求这些宏只能被定义。
的#define __STDC_FORMAT_MACROS
#包括LT&;&inttypes.h GT;...现在PRIu64将工作
I wrote a very simple test code of printf uint64_t:
#include <inttypes.h>
#include <stdio.h>
int main()
{
uint64_t ui64 = 90;
printf("test uint64_t : %" PRIu64 "\n", ui64);
return 0;
}
I use ubuntu 11.10 (64 bit) and gcc version 4.6.1 to compile it, but failed:
main.cpp: In function ‘int main()’:
main.cpp:9:30: error: expected ‘)’ before ‘PRIu64’
main.cpp:9:47: warning: spurious trailing ‘%’ in format [-Wformat]
解决方案
The ISO C99 standard specifies that these macros must only be defined if explicitly requested.
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
... now PRIu64 will work
这篇关于如何给printf uint64_t中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文