From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17532 invoked by alias); 20 Apr 2002 16:33:41 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 17513 invoked from network); 20 Apr 2002 16:33:40 -0000 Received: from unknown (HELO mhs.swan.ac.uk) (137.44.1.33) by sources.redhat.com with SMTP; 20 Apr 2002 16:33:40 -0000 Received: from cs-svr1.swan.ac.uk ([137.44.2.59]) by mhs.swan.ac.uk with esmtp (Exim 3.34 #1) id 16yxnU-0005F5-00; Sat, 20 Apr 2002 17:33:12 +0100 Received: from cspcok.swan.ac.uk (cspcok [137.44.2.97]) by cs-svr1.swan.ac.uk (8.11.3/8.11.3/SuSE Linux 8.11.1-0.5) with ESMTP id g3KGXdG15217; Sat, 20 Apr 2002 17:33:39 +0100 Received: (from csoliver@localhost) by cspcok.swan.ac.uk (8.11.6/8.11.6/SuSE Linux 0.5) id g3KGUB931599; Sat, 20 Apr 2002 17:30:11 +0100 Date: Sun, 21 Apr 2002 00:52:00 -0000 From: Oliver Kullmann To: gcc-help@gcc.gnu.org Subject: Re: Array Initialization warnings Message-ID: <20020420173010.A31575@cspcok.swan.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.22.1i X-SW-Source: 2002-04/txt/msg00221.txt.bz2 > Hi David, > > > Just to clarify...the standard requires the brackets be placed as in > > your example? If so, guess I had best get to bracketing my arrays. > > > It is pretty much up to you, how you handle your arrays. You can > certainly use multi dimentional arrays and initialise them as such, > or you could use one dimentional arrays and initialise them as such. > There is nothing wrong with interpreting an x dimentional array as an > y dimentional array, i am just saying, that you ought to be consistent. > Your original code depended on a particular physical layout of the > array. I am not sure, that physical layout is required by the standard. > > >I really did not want to have to go back and recode my array that looks > >like this:BYTE SUBIMG_NTSC[2][2][4][3][8] = {... > > You might want to wait with a rewrite, until someone makes > a stronger statement about this;) > > Yours sincerely, > bjorn Hi, I copied a paragraph from the standard (ISO/IEC 14882:1998(E)): When initializing a multi-dimensional array, the initializers initialize the elements with the last (rightmost) index of the array varying the fastest (8.3.4). [Example: int x[2][2] = { 3, 1, 4, 2 }; initializes x[0][0] to 3, x[0][1] to 1, x[1][0] to 4, and x[1][1] to 2. On the other hand, float y[4][3] = { { 1 }, { 2 }, { 3 }, { 4 } }; initializes the first column of y (regarded as a two-dimensional array) and leaves the rest zero. ] (paragraph 8.5.1) Oliver