Wherever the code refers to a variable or function, the compiler only allows this if it has previously seen a declaration for that variable or function—the declaration is a promise that a definition exists somewhere else in the whole program.
The notable exception here is implicitly declared functions, but they were dropped in C99 anyway.
Indeed. After reading the OP and finally getting a handle on how linkers, assemblers, compilers, etc. work, I asked myself why functions weren't just implicit. Turns out K&R thought the same, but the solution sucked because it assumes an int return, which may not be what the function actually returns.
The `static` keyword in C is too confusing. It's hard to explain to beginners. Especially if these beginners come from Java, where it has even more meanings. I don't understand why we have to use the same keyword over and over again.
There is an ever growing list of overloaded keywords that mean different things to different people and programming languages. And yes, it's confusing. A short list that's semantically fuzzy:
- thread
- type
- class
- module
- functor
- virtual machine
- ...
Often times the reason for overloading keywords is the reluctance to introduce new keywords, as this can cause backward compatibility problems. Instead of adding a new keyword and possibly breaking existing code that may use that keyword as a variable name or a function name, an existing keyword that sort-of fits is used for the new feature.
While maintaining backward compatibility is good, this does make the language confusing. Static is probably one of the worst offenders, but I think that C++ especially has quite a few of these cases now.
I think C (and Unix) was the original context in which the static keyword appeared, and as such, changing its meaning would be a terrible idea. A C programmer has to deal with things a lot more complex than the syntax (which IMHO is much clearer than any more modern language, in the context in which it is most commonly used, i.e. system programming).
So if someone is 'confused' by the fact that a keyword has two different (albeit related meanings) in the language, and is too bothered to check a manual, or the internet for an explanation, how is that person supposed to write a driver or an operating system, or use low level ipc/communication mechanisms, or debug an elusive deadlock? C is not JavaScript, get over it.
Understanding the linking process is a big part of understanding a lot of the problems you'll run into with C--it's great seeing somebody going over this information!
The notable exception here is implicitly declared functions, but they were dropped in C99 anyway.