Re: C Help Magic Square
From: Tim Rentsch (txr_at_alumnus.caltech.edu)
Date: 11/02/04
- Next message: Tim Rentsch: "Re: Can use macros to solve this problem?"
- Previous message: Mike Wahler: "Re: 4-bytes or 8-bytes alignment?"
- In reply to: Jack Klein: "Re: C Help Magic Square"
- Next in thread: Flash Gordon: "Re: C Help Magic Square"
- Reply: Flash Gordon: "Re: C Help Magic Square"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 01 Nov 2004 20:41:54 -0800
Jack Klein <jackklein@spamcop.net> writes:
> On Sun, 31 Oct 2004 21:07:29 -0500, "winnerpl" <winnerpl@hotmail.com>
> wrote in comp.lang.c:
>
> > void fill_square(int[][], int);
>
>> [some snippage]
>
> In any case, the prototype above is not valid C, it is a syntax error.
> There is no such thing as a function array parameter with more than
> one empty '[ ]' pair. If your compiler accepts this, it is either not
> a C compiler or you are not invoking it to operate in standard C
> conforming mode.
Both a prototype and a function definition with an 'int[][]' type were
accepted by 'gcc -(ansi|std=c99) -pedantic' -- some warnings, but no
errors, and certainly no syntax errors. Is gcc in error here?
Or does the standard actually allow this?
Incidentally, the meaning assigned seems to be the same as though
it were like this:
int f( int (*)[] ); /* or int f( int [][] ); */
int f( int (*x)[] ){ /* or int f( int x[][] ){ */
return (*x)[0];
}
extern int a[];
int main(){
return f( &a ) == 0;
}
Of course, I'm making no claim that code like this is sensible.
Only asking if it's legal.
- Next message: Tim Rentsch: "Re: Can use macros to solve this problem?"
- Previous message: Mike Wahler: "Re: 4-bytes or 8-bytes alignment?"
- In reply to: Jack Klein: "Re: C Help Magic Square"
- Next in thread: Flash Gordon: "Re: C Help Magic Square"
- Reply: Flash Gordon: "Re: C Help Magic Square"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|