| 
                  Scope, Storage Duration, and Linkage in C
                   an Introduction  | 
            
| 
                   
                      
                     Prof. David Bernstein
                       | 
            
| Computer Science Department | 
| bernstdh@jmu.edu | 
               
            
         
            
         
         
            
         char, int, void)inline)auto, 
              extern, register,
              static)struct, union,
              enum)
         
            
         
         
            
         
         
            
         n is not declared
            in the scope of main()
                           
                        
                     
                        
                     
         
            
         n has file scope
            
                        
                     
                        
                     
         
            
         n with file
            scope and an n with local scope
            
                        
                     n is not
            initialized.
                        
                     
         
            
         n with file
            scope and an n with local scope
            
                        
                     
                        
                     
         
            
         malloc()) and 
              ends at deallocation (e.g., free())
         
            
         static specifier
            can be used in the declaration of a varaible with block scope
            
                        
                     
                        
                     
         
            
         
         
            
         
         
            
         
                        
                     validate() in
            main() is undefined because validate()
            has internal linkage
                        
                     
         
            
         
                        
                     
                        
                     
         
            
         
         
            
         
         
            
         
         
            
         extern == Yes:
      extern == No or static == Yes):
      = 0 or = {0}
              if there is no definition in the same translation
              unit)
         
            
         
         
            
         account.h and
              account.c
                     driver.c that
              uses the library
         
            
         
         
            
         account.h is in
              both translation units
                        
                     multiple definition of 'acct_status'
              because acct_status has been defined in both
              translation units 
              
                        
                     
         
            
         
         
            
         'acct_status' was not declared in this scope
                           
                        
                     
                        
                     
         
            
         
         
            
         account.c will compile but
              driver.c won't
                        
                     
                        
                     
         
            
         
         
            
         acct_status
              is only declared in account.h, not defined
              
                        
                     undefined reference to 'acct_status'
              because it has been declared but not defined