??? 09/19/06 06:51 Read: times |
#124528 - Module vs Global scope Responding to: ???'s previous message |
Russ Cooper said:
Module Variable This is one that's defined at file scope (outside of any function) and is therefore visible to all the functions within the same C source file (module). However, unless it's also declared in an (evil) extern statement somewhere, it's not visible to other modules. Actually, that's not true in 'C' In 'C', all symbols defined at file scope are automatically global unless you specifically restrict them to file scope by using 'static'. If a symbol is undeclared, a 'C' compiler will just assume that it's an extern int. If the Linker later finds a public definition of the symbol name, it will make the link. If you're lucky, you'll get away with it. But this gives no check that the public definition found matches the external declaration assumed... Global Variable This is one that's defined at file scope and declared in an (evil) extern statement so that it is visible outside the module in which it's defined. For 'C', see above |