Mail Archives: djgpp/1998/07/27/19:16:18
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 <dpmi.h>
#include <go32.h>
#include <stdio.h>
#include <conio.h>
#include <sys/movedata.h>
#include <sys/farptr.h>
#include <string.h>
#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<<bitnum)); }
int clearbit (int &input, int bitnum)
{ return ((input)&(~(1<<bitnum))); }
int testbit (int input, int bitnum)
{ return (( (input) & (1<<bitnum) ) >= 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
- Raw text -