www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/01/09:56:32

From: "DeHackEd" <notgiven AT out DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <19990101025458 DOT 11224 DOT 00005570 AT ng37 DOT aol DOT com>
Subject: Re: multiple file compiling
Lines: 26
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.0810.800
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.0810.800
Message-ID: <Ll4j2.3273$fz5.77@tundra.ops.attcanada.net>
Date: Fri, 1 Jan 1999 09:51:28 -0500
NNTP-Posting-Host: 142.194.222.204
X-Trace: tundra.ops.attcanada.net 915198443 142.194.222.204 (Fri, 01 Jan 1999 13:47:23 GMT)
NNTP-Posting-Date: Fri, 01 Jan 1999 13:47:23 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Probably the best thing to do is make a .H file every C file includes. This H
file would include prototypes for all shared functions and variables.

As for defining variables, in 1 C file only, use "int ROOM;" as you normally
would. In the header file, or in each C file that needs this variable, use
"extern int ROOM;" This tells the compiler the variable exists, but isn't
defined in this C file. Make sure you link the first one with the second one or
the linker will give you UNDEFINED REFERENCE TO _ROOM.

Twidler444 <twidler444 AT aol DOT com> wrote in message
news:19990101025458 DOT 11224 DOT 00005570 AT ng37 DOT aol DOT com...
>Hello, Im trying to make a game.  This game is pretty long, so I have decided
>to chop the program into different parts.  and have these different parts of
>the game in their own file.  The only problem is how do I do the sharing of
>variables.
>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
><second.cpp>)
>
>
>any help would be usefull
>
>
>Twidler


- Raw text -


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