From: Karsten Newsgroups: comp.os.msdos.djgpp Subject: Problems with "multiple definition"'s in a header file Date: Tue, 28 Jul 1998 00:18:34 -0700 Organization: - Lines: 67 Message-ID: <35BD7B4A.75E@alpha.futurenet.co.za> Reply-To: karsten AT alpha DOT futurenet DOT co DOT za NNTP-Posting-Host: dialup10.futurenet.co.za Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hi! Im having major problems when trying to break up a large program into smaller .h files. I get "multiple definition" errors for almost eveything I declare. I have looked at style guides, c/c++ FAQ's, shown my code to other c programmers, and so far I've come up with nothing that solves my problem. My code is given below: (I cut it down to a minimum). I get multiple definitions on 'regs', 'setbit', 'testbit' and 'clearbit'. Ive also tried commenting out various bits in all sorts of combinations from the code below with no luck. Could someone please help me out? Any help/suggestions would be greatly appreciated! ---------- globals.h -------------------------------------------- #ifndef GLOBALS_HEADER #define GLOBALS_HEADER #include #include #include #include #include #include #include #define tb_offs __tb & 0x0f #define tb_seg (__tb >> 4) & 0xffff extern __dpmi_regs regs; extern int setbit (int input, int bitnum); extern int clearbit (int &input, int bitnum); extern int testbit (int input, int bitnum); #endif // GLOBALS_HEADER ---------- globals.cc ------------------------------------------- #include "globals.h" __dpmi_regs regs; int setbit (int input, int bitnum) { return ((input)|(1<= 1); } ------- test.cc ----------------------------------------------- #include "globals.h" void main() { regs.x.ax=5; printf ("Hello world\n"); } --------------------------------------------------------------- Thanks! Karsten karsten AT alpha DOT futurenet DOT co DOT za