public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: ahaas@airmail.net (Art Haas)
To: linux-mtd@lists.infradead.org
Subject: [PATCH] C99 initializers for drivers/mtd files
Date: Mon, 3 Mar 2003 15:33:17 -0600	[thread overview]
Message-ID: <20030303213317.GB6239@debian> (raw)
In-Reply-To: <1046726489.2672.641.camel@tubarao>

On Mon, Mar 03, 2003 at 02:21:29PM -0700, Thayne Harbaugh wrote:
> Hmmm.  I guess C99 mostly works - with the exception of array
> initializers:
> 
> [thayne at tubarao tmp]$ cat foo.c
>                                                                                 
> struct foo {
>   int bar;
>   int baz;
> };
>                                                                                 
> struct foo fufu[] = {
>   [0].bar = 0,
>   [0].baz = 0
> };
>                                                                                 
> [thayne at tubarao tmp]$ gcc -c foo.c
> foo.c:8: unknown field `bar' specified in initializer
> 
> It's the array initialization that I want to use.  Grrrr!
> 
> 

Array initializers should work in GCC-2.95.X also, your syntax is just a
little off ...

$ cat foo.c
struct foo {
	int bar;
	int baz;
};
                                                                                
struct foo fufu[] = {
	[0] = {
		.bar = 0,
		.baz = 0
	},
};

$ gcc-2.95 -c foo.c
$
$ gcc-2.95 -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)
$

The above foo.c compiles fine with gcc-3.2 and gcc-3.3 also. The C99
syntax should be no problem for gcc-2.95, or really any GCC release
after gcc-2.5, as gcc-2.5 is where the current documents say the syntax
with the ":" became obsolete.

Art Haas

-- 
They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety.
 -- Benjamin Franklin, Historical Review of Pennsylvania, 1759

  reply	other threads:[~2003-03-03 21:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-26 20:53 [PATCH] C99 initializers for drivers/mtd files Art Haas
2003-02-27 19:44 ` Jörn Engel
2003-02-27 21:46   ` Art Haas
2003-03-02 18:56     ` Jörn Engel
2003-03-03 20:49       ` Thayne Harbaugh
2003-03-03 21:06         ` Jörn Engel
2003-03-03 21:21           ` Thayne Harbaugh
2003-03-03 21:33             ` Art Haas [this message]
2003-03-03 21:41               ` Thayne Harbaugh

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=20030303213317.GB6239@debian \
    --to=ahaas@airmail.net \
    --cc=linux-mtd@lists.infradead.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