Path: utzoo!attcan!uunet!samsung!usc!orion.oac.uci.edu!uci-ics!gateway From: rfg@paris.ics.uci.edu (Ronald Guilmette) Newsgroups: comp.std.c Subject: Is "int (*ptr)[][];" a legal declaration? Message-ID: <2608FAF7.25668@paris.ics.uci.edu> Date: 22 Mar 90 16:19:03 GMT Organization: UC Irvine Department of ICS Lines: 33 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@ics.uci.edu) // C++ Entomologist // Motto: If it sticks, force it. If it breaks, it needed replacing anyway.