Mail Archives: djgpp/1999/05/12/18:40:54
salvador wrote:
> > 12 : for(treD_vertice *p = first; p->next; p=p-next)
> > 13: p->next = new treD_vertice(0,x,y,z)
> > 13 : name lookup of 'p' changed for new ANSI 'for' scoping
> > 12 : using obsolete binding at 'p'
>
> Is very clear and far from cryptic, the compiler is telling you that ANSI
> says p will be available *outside* the loop, but looks like you want it to
> be only inside the loop. Just avoid declaring the variable in this way,
> declare it outside the for and it will work in any compiler.
That's not actually what it means. It means that ANSI says that p will
only be available INSIDE the loop and he has used it AFTER/OUTSIDE the loop.
The new ANSI C++ rules for scope of a variable declared are INSIDE the for
loop. If you try to use it outside (after) the for loop in DJGPP you will get
this message.
This program compiles fine:
-----------------------------
#include <stdio.h>
int main()
{
double d;
char Test[80];
int p=6;
for(int p=0; p<100; p++)
printf("%d", p);
p++;
}
---------------------------
But, if the line 'int p=6;' is left out, that exact warning message will
be displayed. In this case there are 2 different 'p' variables one with scope
inside the for loop and one with scope outside the for loop inside the main
function.
--
(\/) Endlisnis (\/)
s257m AT unb DOT ca
Endlisnis AT HotMail DOT com
ICQ: 32959047
- Raw text -