Reputation: 9263
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 know if there is a way to avoid the warning WITHOUT casting each time of course!
Upvotes: 1
Views: 903
Reputation: 108978
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 */
Upvotes: 0
Reputation: 182639
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.
Upvotes: 8