fir said:
I do not know if c authors meant c modules to be globally linked, It
would be nicer to me to hear that they meant local linking more than
global - and this mistake is an linker makers (or something?)
contribution
(When you say "modules", do you mean "translation units"? If so,
it would help if you'd use the standard terminology; if not, what
exactly is a "module"?)
It seems clear enough, to me at least, that the designers of
C intended what you call global linking. Take a look at the
description of translation phase 8 in the C standard:
All external object and function references are resolved. Library
components are linked to satisfy external references to functions
and objects not defined in the current translation. All such
translator output is collected into a program image which
contains information needed for execution in its execution
environment.
It says nothing about the possibility of the same identifier in
two different translation units referring to two different external
symbols. If the kind of mechanism you suggest were intended, surely
the standard would have mentioned it, especially given that there
has to be a way to specify *which* symbol a given identifier in a
give translation unit refers to.
You've been using "printf" as an example of an identifier that
might have different meanings in different parts of a program.
I suggest that that's not a good example. Since "printf" is part
of the standard library, its name is reserved; a program that
defines its own "printf" at file scope has undefined behavior.
Even if that rule were to be relaxed, using "printf" to refer to
something other than the standard function would be confusing.
I suggest that something that a program can define for itself would
make for a better example.