Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > C99 structure initialization in gcc-2.95.3 vs gcc-3.3.1

Reply
Thread Tools

C99 structure initialization in gcc-2.95.3 vs gcc-3.3.1

 
 
Kevin P. Fleming
Guest
Posts: n/a
 
      11-06-2003
I've got an enum and a structure:

enum option_type {
O_STRING,
O_BOOL,
O_NUMBER
};

struct option_s {
char *name;
enum option_type type;
char *value;
char *def_value;
};

I want to define and initialize an instance of this structure:

static struct option_s foo_option = {
.name = "foo",
.type = O_STRING,
.def_value = "default"
};

With gcc-3.3.1, this works fine. With gcc-2.95.3, it complains about a
"missing initializer for .value". However, I know that the Linux kernel
uses this type of structure initialization, and it compiles OK with
gcc-2.95.3. Any ideas what's up here? I don't think this is actually a
syntax error on my part...

 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      11-06-2003
"Kevin P. Fleming" <(E-Mail Removed)> writes:

> With gcc-3.3.1, this works fine. With gcc-2.95.3, it complains about a
> "missing initializer for .value". However, I know that the Linux
> kernel uses this type of structure initialization, and it compiles OK
> with gcc-2.95.3. Any ideas what's up here? I don't think this is
> actually a syntax error on my part...


You'd be better off asking about this in a GCC-related newsgroup.
The C standard doesn't say anything, either way, about warnings
in this case (or in any case), and we don't discuss
compiler-specific issues here.
--
"It wouldn't be a new C standard if it didn't give a
new meaning to the word `static'."
--Peter Seebach on C99
 
Reply With Quote
 
 
 
 
Kevin P. Fleming
Guest
Posts: n/a
 
      11-06-2003
Ben Pfaff wrote:

> You'd be better off asking about this in a GCC-related newsgroup.
> The C standard doesn't say anything, either way, about warnings
> in this case (or in any case), and we don't discuss
> compiler-specific issues here.


OK, will do.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between "library parts" of C99 and "language parts" of C99 albert.neu@gmail.com C Programming 3 03-31-2007 08:14 PM
C99 struct initialization (C99/gcc) jilerner@yahoo.com C Programming 3 02-20-2006 04:41 AM
Initialization of non-integral type in initialization list anongroupaccount@googlemail.com C++ 6 12-11-2005 09:51 PM
Initialization via ctor vs. initialization via assignment Matthias Kaeppler C++ 2 07-18-2005 04:25 PM
Default Initialization Vs. Value Initialization JKop C++ 10 09-22-2004 07:26 PM



Advertisments