circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 
Test Your EQ #160—Answer

Answer 1—The GLOBAL preprocessor symbol allows the same text in the module's header file to function as both the declaration and definition of global symbols (functions and variables) associated with the module.

When a module includes header files from other modules, GLOBAL expands to extern, and each header file serves to declare the symbols from the other modules for the current module.

When a module includes its own header file, GLOBAL expands to nothing, and the header file serves to define that module's own global symbols. The advantage of this approach is that there is only one file that needs to be modified when a module's globals are changed, and separate declarations and definitions don't need to be kept in sync manually.

 

Contributor: David Tweed

Published November 2003

   

E-mail eq@circuitcellar.com with questions or comments.

Back to Questions