In 'comp.lang.c', ravi_shankar <me*********@dbforums.com> wrote:
what's the advantage of prefixing a varible with "extern" storage class
specifier other than its default initializion .
It's ignored when you define the variable, but it allows a separated
declaration of this variable when you want it to be shared in different
modules.
1 - Are you sure you need a global scope variable?
2 - If so, define it in a source file (say data.c)
3 - Declare it in a header (say data.h>
4 - For consitency, include this header in th definition file (data.c) and
all the files that need a reference to this variable.
5 - For readability and maintenance, I suggest that the global scope
variables are prefixed with G_
/* data.h */
#ifndef H_DATA
#define H_DATA
extern int G_myglobal;
extern int G_myarray[123];
#endif
/* data.c */
#include "data.h"
int G_myglobal;
int G_myarray[];
--
-ed-
em**********@noos.fr [remove YOURBRA before answering me]
The C-language FAQ:
http://www.eskimo.com/~scs/C-faq/top.html
<blank line>
FAQ de f.c.l.c :
http://www.isty-info.uvsq.fr/~rumeau/fclc/