Thanks, that's a great idea. Unless someone comes up with some magic
flag, I'll do that.
Now, please believe me that I wouldn't think about putting declarations
in the middle of code in my own sources. But obviously some people do,
and get away with it. And then I want to compile their code.
So there is no point telling me that something is forbidden, when some
people do it and I get the punishment. ;)
Eli
Ilya A. Volynets-Evenbakh wrote:
> First of all, C does not allow mixing code and declarations. Period.
> Second, variable-size arrays aren't allowed by ANSI C either.
> However, GCC does have an extension, which allows things like that.
>
> What I'd do, is move the for loop in the second example into a separate
> (perhaps static inline) function. Something like:
>
> #include <stdio.h>
> int count_arr(char *arr[])
> {
> int i;
> for (i=0; arr[i]!=NULL; i++);
> return i;
> }
>
> int main(int argc, char argv[])
> {
> char my_array[count_arr(argv)];
> .....
> }
>
>
>
>
_______________________________________________
Haifux mailing list
[email protected]
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux