making sense of directives in headers

Discussion created by ROB LUND on Oct 6, 2011
Latest reply on Oct 6, 2011 by kef

Hey all.  I've got some Freescale sample code and I'm trying to decode their use of compiler directives.  Here's a sampling from the project's main.h file:


#undef EXTERN#ifdef MAIN#define EXTERN#else#define EXTERN extern#endif#ifndef _MAIN_H#define _MAIN_H

 What's going on here?  I see they are looking for the definition of the macro "MAIN", then defining EXTERN.  But what's the point?  the reserved type "extern" is part of the language, why would it need to be defined?


Same goes for the macro "_MAIN_H".  Are those even necessary if the linker does the work of referring to all prototypes and macro names from this header file and associating to the main.c file?


I feel like my foundational questions are tipping into computer programming theory.  Perhaps I'm wrong.