C99 structure initialization in gcc-2.95.3 vs gcc-3.3.1

Discussion in 'C Programming' started by Kevin P. Fleming, Nov 6, 2003.

  1. 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...
     
    Kevin P. Fleming, Nov 6, 2003
    #1
    1. Advertising

  2. Kevin P. Fleming

    Ben Pfaff Guest

    "Kevin P. Fleming" <> 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
     
    Ben Pfaff, Nov 6, 2003
    #2
    1. Advertising

  3. 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.
     
    Kevin P. Fleming, Nov 6, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peng Yu
    Replies:
    2
    Views:
    727
    Default User
    Sep 29, 2004
  2. MikeyD

    dumb q moving to gcc - c99 mode

    MikeyD, Sep 19, 2003, in forum: C Programming
    Replies:
    7
    Views:
    571
    John Tsiombikas (Nuclear / the Lab)
    Sep 21, 2003
  3. Svein E. Seldal

    GCC structure initialization

    Svein E. Seldal, May 14, 2004, in forum: C Programming
    Replies:
    2
    Views:
    3,721
    Martin Ambuhl
    May 14, 2004
  4. Replies:
    3
    Views:
    3,705
    Chris Torek
    Feb 20, 2006
  5. Replies:
    3
    Views:
    611
    Keith Thompson
    Mar 31, 2007
Loading...

Share This Page