【发布时间】:2011-04-05 07:38:37
【问题描述】:
已编辑以删除第一个警告
以下代码在 mingw32 下的 g++ 4.4.0 中按预期工作:
#include <cstdio>
int main()
{
long long x = 0xdeadbeefc0defaceLL ;
printf ("%llx\n", x) ;
}
但如果我用-Wall 启用所有警告,它会说:
f.cpp: In function 'int main()':
f.cpp:5: warning: unknown conversion type character 'l' in format
f.cpp:5: warning: too many arguments for format
%lld 也一样。这个问题在新版本中修复了吗?
再次编辑添加:
如果我指定 -std=c++0x,警告不会消失,即使 (i) long long 是标准类型,并且 (ii) %lld 和 %llx 似乎得到官方支持。例如,从 21.5 数字转换第 7 段:
Each function returns a string object holding the character representation of the value of
its argument that would be generated by calling sprintf(buf, fmt, val) with a format specifier of
"%d", "%u", "%ld", "%lu", "%lld", "%llu", "%f", "%f", or "%Lf", respectively, where buf designates
an internal character buffer of sufficient size.
所以这肯定是一个错误?
【问题讨论】: