_MAIN_H should be simple. It is often used to prevent double inclusion of H file, like
//start of H-file
#ifndef __MAIN_H
#define __MAIN_H
// H-file body
#endif
// end of H-file
Regarding EXTERN. Having lots of exported variables, it makes sense to define them in one place to avoid typing or copying errors. But while declaring variables, you need to use extern keyword, while defining the same variables you need to have no extern. And that is purpose of EXTERN. In main.c you define MAIN (or maybe better MAIN_C,) before #include "main.h". In all other files MAIN is not defined. All variables are then are defined and declared in one place, only in main.h like this:
EXTERN int intvar;
EXTERN char cvar;
The problem here is what to do with variable initializers like int a=10;? Initializer abandons extern keyword. So to continue using EXTERN-like stuff with initializers you probably need to use additional macros like
makevariable(type varname, initializer)
, which would expand like
.
extern type varname; //when MAIN is not defined
and
type varname=initializer; // when MAIN is defined