1

I'd like to enable/disable some c compiler warnings for some specific portions of code. For example for the code

printf("code: %i", code, subcode);

i (obviously) get a warnings like "warning: too many arguments for format [-Wformat-extra-args]"

I know I can pass the -Wformat-extra-args to the compiler to get rid of such warnings, but I do not want that for all code, only for some portions, i'm thinking something like

#pragma disable format-extra-args
printf("code: %i", code, subcode);
#pragma enable format-extra-args

is that feasible ?

gtosto
  • 1,381
  • 1
  • 14
  • 18
  • Interesting example. I assume it is much more complicated (squelching warnings from really crappy headers of really crappy 3rd party libraries and such). Otherwise, one has to ponder: if you're right there in the code and willing to splay a fencepost set of warning disablement around it, why not just *fix* the code in the first place. – WhozCraig Feb 27 '22 at 10:25

0 Answers0