我想测试一个非常简单的代码,但Visual Studio 2010没有编译它.这是我第一次使用带结构的指定初始化程序,但它似乎是100%正确的,因为它只是来自维基百科的简单复制和粘贴.
代码是:
#include/* 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将.y中的点标记为红色.有谁知道发生了什么?我在互联网上搜索了其他参考文献,但我看不出为什么我的代码错了.VS2010不支持C功能吗?
Visual Studio 2010 c
编译器仅支持C89.指定的初始化程序是C99功能.