delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/04/20:49:54

From: qball1723 AT aol DOT com (QBall1723)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: extern problem
Date: 5 Jan 1998 01:42:12 GMT
Lines: 38
Message-ID: <19980105014201.UAA09449@ladder02.news.aol.com>
NNTP-Posting-Host: ladder02.news.aol.com
Organization: AOL http://www.aol.com
References: <34AD61B8 DOT 8C4CF871 AT IHateSpam DOT com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>I'm having a problem with the extern keyword.  I'm doing a multi-file
>project in RHIDE, and I'm declaring something I want all the functions
>to be able to acess above my main and then in the other files declairing
>it the same way with the extern keyword before it.  The problem is that
>the variables are all equal to 0 when I use extern, but they have values
>in them in main. Can anyone tell me what I'm doing wrong.  Here's an
>example of what I'm doing:
>
>extern Sprite sprite;                        //sprite being a tydefined
>structure
>
>

This might not be the best advice.... but pass the sprite (or a sprite pointer)
as a parameter....

as far as other externals... here's what I did...

in the modules... let's say they're called modey.h & modey.c

declare variables as extern in the .H (again - no assignments there)

in the .C ... declare the variables as you normally would...
(so you have 2 declarations)

Now... let's say the project uses.... implement.c (the main procedure is in
it)... and the file modey.c....

put #include "modey.h" in BOTH .C sources....

actually - you can do that with the sprites too...

I hope this helps....


Jim the loiterer (wannabe PC game/graphics developer)
http://members.aol.com/qball1723/index.htm
[please don't hate me because I pay too much for poor internet service!!]

- Raw text -


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