Bartc wrote, On 05/05/08 10:53:
> I noticed that in C, functions in any module are automatically ex****ted.
So
> that it's not possible to use the same function name in two modules (ie.
> source files).
Your C text book should have told you this. If not you need to reread it
and/or replace it.
> Now that I know that, I get work around it; but is there a way to avoid
the
> problem (short of lots of renaming)?
>
> More seriously, variables declared at file scope also seem to be
> automatically ex****ted.
Yes.
> But in this case, the compiler/linker doesn't warn
> me that the same name is being used in two or more modules.
It is not required to. Some can be made to however, so you should read
the do***entation for your implementation.
> (Is this what
> the fuss is about with 'global variables'?)
High coupling making it hard to understand programs. You have to read
every function (or you search facilities on the entire code base) to
find out when and how the variables are changed and where they are used,
then you find you have a problem because you cannot change one piece of
code without breaking lots more.
The larger the project the larger the problem.
> Is there any way I can fix this? (Like some keyword that will render a
> variable local to a module.)
Look up the many uses of static in your text book.
--
Flash Gordon


|