A codebase I work with has historically tried--purposefully--to avoid dependencies on stdio.h creeping in. It has its own print formatting and mechanisms, and those are what's supposed to be used instead of printf etc.
But someone adds a dependency every so often that has to get noticed and taken out. So I tried to make an alarm for the easiest of cases:
#if !defined(NDEBUG)
void printf(float dont_link_with_stdio_h);
#endif
The gcc people seem to have been thinking along the lines of stopping easy errors too, because there's a helpful message if you do this...whether you've included <stdio.h>
or not.
conflicting types for built-in function 'printf'
There's a way to turn this warning off (-fno-builtin
). And there are all kinds of approaches that would do things like filter the symbol dump for things you don't want to be there...
But is there a trivially easy non-warning-causing (if you didn't include stdio.h) way to alert someone that they've introduced an unwanted printf usage?