From: Oliver Kullmann <O.Kullmann@swansea.ac.uk>
To: gcc-help@gcc.gnu.org
Subject: Re: Array Initialization warnings
Date: Sun, 21 Apr 2002 00:52:00 -0000 [thread overview]
Message-ID: <20020420173010.A31575@cspcok.swan.ac.uk> (raw)
> 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
next reply other threads:[~2002-04-20 16:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-21 0:52 Oliver Kullmann [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-04-20 8:37 David Stroupe
2002-04-20 9:33 ` bjorn rohde jensen
2002-04-20 6:58 David Stroupe
2002-04-20 7:06 ` Michal Liptak
2002-04-20 7:53 ` bjorn rohde jensen
2002-04-24 11:09 ` Sebastian Huber
2002-04-24 12:09 ` bjorn rohde jensen
2002-04-20 6:30 David Stroupe
2002-04-20 6:56 ` bjorn rohde jensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020420173010.A31575@cspcok.swan.ac.uk \
--to=o.kullmann@swansea.ac.uk \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).