www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/21/02:15:25

From: "Tony O'Bryan" <aho450s AT nic DOT smsu DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Large global arrays in C++
Date: Thu, 20 Nov 1997 14:12:00 -0600
Organization: Southwest Missouri State University
Lines: 16
Message-ID: <34749990.B1E@nic.smsu.edu>
References: <01bcf5e7$b71098e0$533463c3 AT mrbcomp>
Reply-To: aho450s AT nic DOT smsu DOT edu
NNTP-Posting-Host: marie.a33.smsu.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Matthew Bennett wrote:

> 2) As large global arrays are needed for many games I'm writing, is there
> any way I can get round this problem?? Surely others must have needed a
> workaround too?

	Anytime you need a non-trivial array (whether global or local),
malloc() or new it rather than hard-coding it into the program.  If the
data can't be generated at run-time (such as game levels), create a file
that gets loaded into a malloc()/new array.

	This reminds me of an answer I meant to give John a while back about
his problem making gcc compile a huge gobal array.  I compiled and ran
your program that created the global array source file, then compiled
that program under Linux's gcc without any problem.  So not all gcc
implementations have the problem you encountered with DJGPP.

- Raw text -


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