In the GCC manual:
-Wmissing-prototypes (C and Objective-C only)
Warn if a global function is defined without a prior prototype declaration. This warning is issued even if the definition itself provides a prototype. The goal is to discover global functions that cannot be declared in header files.
Clang borrowed this option for GCC compatibility and because it is useful (I would suggest this from Clang developers).
The option exists, so you can prevent you from making a general mistake that can be easily avoided. It's nice to be frank about visibility / anchor for clarity / intention.
In short, you asked the compiler to tell you when an unqualified definition does not match the declaration by enabling this option. You must either qualify it as extern and make it usable by others (for example, put it in the header), or declare it static . If using C ++ inline also an option.
Of course, implicit visibility is well known, but I usually find this option useful in these scenarios:
1) I made a typo:
and
2) I must clearly indicate the visibility of the symbol:
3) I forgot the #include header, which declared the function:
Attention:
No warning:
// file.m
Thus, there is rationale, history, and some examples - again, -Wmissing-prototypes . If you trust yourself to work with it disabled, do it. My preferences should be clear and allow programs to detect potential and current problems, so I do not need to do this manually.
source share