Mail Archives: djgpp/1999/11/03/23:30:41
"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 -