C99 structure initialization in gcc-2.95.3 vs gcc-3.3.1

  • Thread starter Kevin P. Fleming
  • Start date
K

Kevin P. Fleming

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...
 
B

Ben Pfaff

Kevin P. Fleming said:
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.
 
K

Kevin P. Fleming

Ben said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top