Mail Archives: djgpp/1995/12/19/17:39:22
In your message dated Tuesday 19, December 1995 you wrote :
> Re this short program with an error (name omitted after `double'):-
> int zxcvbnm(int i, int j, double[i][j]){int k; k=2; return 42;}
Well you're defining the dimensions of the array in terms of the paramaters -
they should be constant, coz we don't get dynamic arrays unless we write 'em
ourselves in C++.
> When I compiled it (with djgpp) as C++, the compiler swore at me thus:-
>
> t$$.cc:1: `i' was not declared in this scope
> t$$.cc:1: `j' was not declared in this scope
> Segmentation violation in pointer 0x00000008 at d8:5cebc
>
> EXCEPTION OCCURRED! Information dumped to core file:
> "t$gccdbg"
>
> but compiled as C the compiler said nothing.
Yes, in C, it's optional to include the name in a /forward/, but it must be
included in the body. However, the compiler may be dreaming of the old syntax:
hello(i,j,k)
int i;
float j;
unsigned char *k[1024][];
{
puts("Hello, mom!");
}
Apart from those near-allowabilities, it looks like a bug :-)
Regards,
ABW
--
Alaric B. Williams (alaric AT abwillms DOT demon DOT co DOT uk)
"A man walks into a bar, right, and he goes 'ouch' coz it's an iron bar"
- Raw text -