Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!orion.oac.uci.edu!uci-ics!gateway From: rfg@paris.ics.uci.edu (Ronald Guilmette) Newsgroups: comp.std.c Subject: Simple questions about array declarations Message-ID: <25E833AA.15362@paris.ics.uci.edu> Date: 25 Feb 90 19:36:10 GMT Organization: UC Irvine Department of ICS Lines: 62 I have several trivial questions about array declarations. I'm just trying to figure out what is considered legal based on sections 3.5, 3.5.4.2, and 3.5.7 of the December 1988 draft. In section 3.5.7 it says: "The type of the entity to be initialized shall be an object type or an array of unknown size." I do not understand what that last part of the sentence is trying to say. Does this mean that the following declaration is illegal? int array1[3] = { 1,2,3 }; /* size is known! */ How about the following pair of declarations? Are these legal or illegal? extern int array2[3]; int array2[] = { 1,2,3 }; /* size is known! */ Now assuming that the above pair of declarations is legal, how about the following pairs? Are these legal? extern int array3[4]; /* size = 4 words */ int array3[] = { 1,2,3 }; /* size = 3 words! */ extern int array4[3]; /* size = 3 words */ extern array4[] = { 1,2,3,4 }; /* size = 4 words */ In the above example, the array sizes are apparently in conflict, but those are cases where the conflict involves an array size which is derived implicitly from an initializer. How about the following examples, in which the array size conflicts do not involve array sizes derived implicitly from initializers? Are these legal or illegal? extern int array5[4]; int array5[3]; extern int array6[3]; int array6[4]; Finally, is there any legal way to "forward declare" a static-linkage array? For example, are any of the following pairs of declarations legal? static int array7[]; static int array7[3] = { 1,2,3 }; static int array8[3]; static int array8[3] = { 1,2,3 }; static int array9[3]; static int array9[] = { 1,2,3 }; static int array10[]; static int array10[] = { 1,2,3 }; // Ron Guilmette (rfg@ics.uci.edu) // C++ Entomologist // Motto: If it sticks, force it. If it breaks, it needed replacing anyway.