delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/07/10:18:28

From: "Bruce Merry (the Almighty Cheese)" <bmerry DOT nospam AT iafrica DOT com>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c
Subject: Can't get external variables to work!??
Date: Sat, 07 Feb 1998 16:48:55 +0200
Organization: Confusion
Lines: 43
Message-ID: <34DC7457.6A0A7521@iafrica.com>
NNTP-Posting-Host: 196-31-84-77.iafrica.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi

I've been using C and C++ for quite a while now, but up to now I've not
needed to share a variable between source files. What I am trying at the
moment is basically (with other stuff removed):

c_types.h:
#ifndef __my_c_types_h
#define __my_c_types_h
typedef unsigned char byte;
#endif

kbd.h:
#ifndef __my_kbd_h
#define __my_kbd_h
#include "c_types.h"
extern byte keys[128];
#endif

program.c:
#include "c_types.h"
#include "kbd.h"
/* stuff with the keys array */

kbd.c:
#include "c_types.h"
static volatile byte keys[128];
/* code for keyboard handling */

Basicly, all the source files compile into objects fine, but at link
time the error 'undefined reference to keys' multiple times. What am I
doing wrong (I'm using DJGPP 2, BTW).

Thanks in advance
Bruce

-- 
Please remove the ".nospam" from my address before replying
/--------------------------------------------------------------------\
| Bruce Merry (Entropy)            | bmerry at iafrica dot com       |
| Proud user of Linux!             | http://www.cs.uct.ac.za/~bmerry |
|     This sentence contradicts itself; no actually it doesn't.      |
\--------------------------------------------------------------------/

- Raw text -


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