Thread: (struct s) {.one = 1}; Is this C99?

  1. #1
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057

    (struct s) {.one = 1}; Is this C99?

    Is this C89? Or C99?

    Code:
    #include <stdio.h>
    
    struct s {
        int one, two;
    };
    
    void func(struct s structure) {
        printf("%i %i\n", structure.one, structure.two);
    }
    
    int main(void) {
        func((struct s) {.one = 5});
        func((struct s) {1});
        func((struct s) {.two = 3, .one = 1});
    
        return 0;
    }
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    It's C99 if I recall correctly.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    It is definitely c99 only. It was not supported in C89. Although some compilers before C99 may have supported such a feature as a non-standard extension.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segfault with Linked List Program
    By kbrandt in forum C Programming
    Replies: 1
    Last Post: 06-23-2009, 07:13 AM
  2. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  3. What's wrong with my search program?
    By sherwi in forum C Programming
    Replies: 5
    Last Post: 04-28-2006, 09:57 AM
  4. Function validation.
    By Fhl in forum C Programming
    Replies: 10
    Last Post: 02-22-2006, 08:18 AM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM