开发者

How to avoid printf warnings about types

I'm wondering if there is a nice way to avoid gcc to scream about printf types : 'warning: format ‘%d’ expects argument of type ‘int’, but argument 12 has type foo'

This is pretty anoying when you know that you wrote 'typedef int foo' somewhere ...

Of course, I'm not looking for the gcc fix for that ( [-Wformat] ).

I would like to kn开发者_如何学Pythonow if there is a way to avoid the warning WITHOUT casting each time of course!


If you have typedef int foo, gcc shouldn't warn you. If gcc is warning you, there's a fair chance foo really isn't an integer.


This has Undefined Behaviour all over. Do not use!

char *fmt;
fmt = "%d%f%p%u\n";
printf(fmt, 1, 1, 1, 1, 1, 1, 1, 1, 1); /* fill stack with values */
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜