Mail Archives: djgpp/1997/02/11/17:31:03
In article <32ffba74 DOT 0 AT ntnews DOT compusmart DOT ab DOT ca>, demandrd AT compusmart DOT ab DOT ca (Demandred) writes:
+->SoMeOnE <bradh AT praxis DOT net> wrote:
+->
+->
+->You're probably not using inclusion guards. Try putting this around
+->your code:
+->
+->#IFNDEF "foo_h"
+->#DEFINE "foo_h"
+->..
+->..
+->..
+->#ENDIF
+->
+->You can #DEFINE whatever you want, but the header filename is usually
+->easiest to remember. Of course, if I did this wrong, it would explain
+->many bugs in my code =) but I'm afraid that's too easy an answer =).
+->
You shouldn't declare any variable in a "*.h" file: you'd better declare them
as 'extern' in this file and ( only once ) declare the vars in a '*.c'.
Why ?
Because declaring a var in a '*.h' declares it several times ( each time the '*.h'
is included )
Example:
in "hungry.h":
#ifdef HUNGRY_C
int my_var;
#else
extern int my_var;
#endif
:
:
:
and:
in "hungry.c":
#define HUNGRY_C
#include "hungry.h"
:
:
:
Hope this helps.
-- sorry for my poor english
Fred.
Frederic Triquet
E-Mail: triquet AT fil DOT univ-lille1 DOT fr
- Raw text -