Is "int (*ptr)[][];" a legal declaration?
Ronald Guilmette
rfg at paris.ics.uci.edu
Fri Mar 23 02:19:03 AEST 1990
Can someone please clarify the rules for me regarding the following
declarations?
At least two non-ANSI C compilers (i.e. Sun4 & Sequent Symmetry) generate an
error for the declaration of p2 below. I don't know if that is correct ANSI
behavior however.
Curiously, these non-ANSI C compilers do *not* also complain about the
declaration of p1.
The GNU C compiler (and the g++ compiler) do not issue any error messages
for this code.
AT&T's cfront translator (for C++) issues error messages for the two lines
indicated. This is also somewhat surprizing.
What should an ANSI C compiler do with this code?
typedef int T;
typedef T array_of_Ts[];
typedef array_of_Ts array_of_array_of_Ts[]; /* error for cfront */
array_of_array_of_Ts *p1;
int (*p2)[][]; /* error for cfront & old C compilers */
// Ron Guilmette (rfg at ics.uci.edu)
// C++ Entomologist
// Motto: If it sticks, force it. If it breaks, it needed replacing anyway.
More information about the Comp.std.c
mailing list