www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/01/11:21:51

Date: Fri, 1 Jan 1999 18:19:59 +0200 (EET)
From: Toni Rasanen <torasane AT mail DOT student DOT oulu DOT fi>
X-Sender: torasane AT paju DOT oulu DOT fi
To: djgpp AT delorie DOT com
Subject: Re: multiple file compiling
In-Reply-To: <19990101025458.11224.00005570@ng37.aol.com>
Message-ID: <Pine.SGI.3.95.990101181531.7523A-100000@paju.oulu.fi>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On 1 Jan 1999, Twidler444 wrote:

> Say I declare the variable ROOM in the main file and also use it in the second
> file. How do I take care of this?  Do I include the second file? (#include

You can't do it that way - or at least it won't be easy.
Easiest way is to make external "variables" -c file, where
you declare _all_ variables, and include it to every other file.

Practically it would be something like this;
vars.c:
  #include <vars.h>
  <define variables here, example; char room [30];>
vars.h:
  <define external variables; extern char room [30];>
room62.c: (one of your part files)
  #include <vars.h>
  <other includes and everything...>
main.c: (main routine)
  #include <vars.h> ...

 ///           Toni Räsänen
///       torasane AT mail DOT student DOT oulu DOT fi
\\\  Physicians ask how. Filosofians ask why. Dragons don't care.

- Raw text -


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