Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!orion.oac.uci.edu!uci-ics!gateway From: rfg@paris.ics.uci.edu (Ronald Guilmette) Newsgroups: comp.std.c Subject: "[][]" revisited Message-ID: <26097D45.1861@paris.ics.uci.edu> Date: 23 Mar 90 01:35:01 GMT Organization: UC Irvine Department of ICS Lines: 49 Lots of people have sent me messages containing their opinions regarding the legality or illegality of declarations like: int (*foo)[][]; But none of these folks has yet produced the smoking gun, i.e. nobody has cited any passage from the ANSI standard that *either* says that this is illegal or that it is illegal. GCC sez it's legal. I have reports that one other "ANSI" C compiler sez that it is legal also, but another "ANSI" C compiler says it's not. Perhaps nobody will ever find any passage that either says "this is legal" or that says "this is not" legal. What's the interpretation in that case? Are all things that are not expressly prohibited allowed? Are all things that are not expressly allowed prohibited? Lemme throw out yet another kinda related question. Which (if any) of the following declarations are legal? extern int two_d_1[][]; /* tenative make is OK? */ int two_d_2[][]; static two_d_3[]; void foobar () { extern int two_d_4[][]; int two_d_5[][]; static int two_d_6[][]; /* ... other unspecified stuff, possibly including complete declarations for the local scope objects... */ } OK. I just thought of one more. The first person to tell me where (in the standard) it sez that this is either legal or illegal wins a free pair of curly-braces! (Good for either home or office use :-) int two_d[][] = { { 1,2,3 }, { 4,5,6 }, { 7,8,9 } }; GCC doesn't like it. I don't see a damn thing wrong with it. Initialize a 3x3 matrix. Why not? // Ron Guilmette (rfg@ics.uci.edu) // C++ Entomologist // Motto: If it sticks, force it. If it breaks, it needed replacing anyway.