3

I wanted to test a very simple code but Visual Studio 2010 isn't compiling it. It's the first time I am using designated initializer with structs but it appears to be 100% correct since it's just a simple copy and paste from the wikipedia.

The code is:

#include <stdio.h>

/* Forward declare a type "point" to be a struct. */
typedef struct point point;
/* Declare the struct with integer members x, y */
struct point {
   int    x;
   int    y;
};

/* Define a variable p of type point, and set members using designated  initializers*/
point p = {.y = 2, .x = 1};

 int main()
{
    point p2 = {.y = 3, .x = 4}; //not even inside main it works
    return 0;
}

Visual Studio marks the dots in .y as red. Does anyone knows what's going on? I searched for other references in the internet and I can't see why my code is wrong. Is VS2010 not supporting a C feature?

1
  • 2
    Designated initializers are available since VS2013 only. Commented Dec 20, 2013 at 4:12

1 Answer 1

11

Visual Studio 2010 c compiler supports only C89. Designated initializers are a C99 feature.

Sign up to request clarification or add additional context in comments.

2 Comments

Really?! So it took microsoft 14 years to comply with a standard? haha
Even now they still only have partial C99 support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.