|
From: Michael G. <mg...@te...> - 2006-05-17 18:33:41
|
> I'm having a problem with a FILE pointer declared inside a header. > When I try to link it, i got an "multiple definition" error. Here is a > small test case: The probelm is you indeed _define_ it twice: wherever you include utils.h the filepointer is defined. What you actually want to do is define it once and _declare_ it everywhere else. There are a couple of mechanisms to achieve that: 1) Copy the line in utils.h into main.c and change utils.h as follows extern FILE *system_log_file; 2) Change utils.h as follows #if defined(IN_MAIN) FILE *system_log_file =3D NULL; #else extern FILE *system_log_file; #endif and insert #define IN_MAIN in main.c before including utils.h There are variations to this but you get the idea. HTH, best, Michael =2D-=20 Vote against SPAM - see http://www.politik-digital.de/spam/ Michael Gerdau email: mg...@te... GPG-keys available on request or at public keyserver |