How can I set a compiler warning (GNU GCC) when overwriting a weak function

Viewed 774

Library functions have the weak attribute set by default (see [1]) and could be "overwritten" with functions having the same signature by accident. For example printf internally calls fputc and I could easily declare one of my functions int fputc(int, FILE *). If that happens, I would like to receive a compiler warning.

Is there a way to tell the compiler to warn me in case of overwriting a weak function?

[1] https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Function-Attributes.html

1 Answers
Related