www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/27/19:16:18

From: Karsten <karsten AT alpha DOT futurenet DOT co DOT za>
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
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019