Actions

EmSys

C - Scope Rules

From EdWiki

Scope Rules

  • The scope of a name(variable, function, macro, etc) is the part of the program within which the name can be used.
  • For an automatic variables declared at the beginning of a function, the scope is the function in which the name is declared. This is true for function parameters also, which are in effect local variables.
  • The scope of a global variable or function lasts from the point at which it is declared to the end of the file being compiled.
  • The scope of a name defined with #define is from its point of definition to the end of the source file being compiled.
  • If a global variable is to be referred before it is defined, or if it is defined in a different source file from the one where it is being used, then an extern declaration is mandatory.