This ad method has one big advantage:
If only one or more functions call an external function, this declaration makes sense, especially in a large source file. If you need to perform a later restructuring of the code (moving the function in another file), it is much easier to see the dependencies than adding external resources to the global (file) area. In the latter case, the probability of “forgetting” such external values in the file is higher. On the contrary, declaring it in the function area, the declaration will move along with the function ...
I also tend to do this for external global variables - the advantage comes later when saving and, ultimately, restructuring / minimizing dependencies.
Last note on the topic “recording external / non-external”: If its just a forward declaration (-> the function is defined at the end of the same file), I would not recommend using an external one - because it is simply not so. Otherwise, it makes sense to indicate externally that the definition should be found somewhere else (or for libaries: perhaps it should be implemented by users of this library).
Hope this helps (as a step towards a more objective style of programming .. :))
topace
source share