Okay, I''m working hard right now, but there''s a problem that I need help with ASAP. It''s very simple and I''ve had it before, but I''ve never been able to figure it out.
Okay, say I have three files: main.c, foo.h, and foo.c.
Here''s main.c:
#include "foo.h"
int main( int argc, char** argv )
{ return 0; } /* ignore how bad this looks */
Here''s foo.h:
#ifndef FOO_H
#define FOO_H
int global1, global2, global3;
#endif
foo.c can basically hold anything, so I''ll ignore that and move on.
To compile this program, foo.c and main.c would first be compiled into respective object files and then linked together.
When I do this, I get an error saying that global1, global2, and global3 are being defined multiple times. What''s wrong? I have the inclusion protection? Is it right? I''m not sure. Can you help me out?