www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/03/23:30:41

From: Weiqi Gao <weiqigao AT a DOT crl DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: GPP Compile problem
Date: Tue, 02 Nov 1999 23:51:58 -0600
Organization: CRL Network Services
Lines: 50
Message-ID: <381FCD7E.9D6AA339@a.crl.com>
References: <s1vhkfam24290 AT corp DOT supernews DOT com>
NNTP-Posting-Host: a116008.stl1.as.crl.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.5-15 i586)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"A. Darrow" wrote:
> 
> [...]
> As it turns out, these two files are completely different
> in each compiler distribution, although they appear to be
> doing the same thing. This may be apropo of nothing.

The two files should be completely different, but they should do exactly
the samething that's specified by the ANSI C++ standard.

> [...]
> The compiler error messages are as follows:
> 
> c:\djgpp\include\istring.cpp: in method 'const class String
>    String::Substr(unsigned int, unsigned int)':
> c:\djgpp\include\istring.cpp:191: name lookup of 'j' changed for new
>    ANSI 'for' scoping:
> c:\djgpp\include\istring.cpp:188: using obsolte binding at 'j':

This error is caused by the fact that the ANSO C++ standard changed the
scoping rules for variables defined in the for() header.  They go away
as soon as the for loop ends now.

> I have a few questions:
> 
> 1. Are some of the header, .cpp, lib files in the DJGPP distribution (v
> 2951) obsolete or out of date?

I don't think so.

> 2. As an aside, since Istring.cpp has a companion, Istring.h ,what is
> Istring.cpp doing that Istring.h cannot or is not doing?

#include-ing a .cpp file feels wrong.  You should make it so that you
only include .h files.

> 3. What is the solution to the aforementioned problem?

If you want to use j after the for loop, j need to be alive before the
for loop:

int j;
for (j = 0; j < 10; j++) {
	// whatever
}
// can use j here.  j should be 10.

-- 
Weiqi Gao
weiqigao AT a DOT crl DOT com

- Raw text -


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