首页 > 编程语言 > 详细

Visual Studio2013的C语言编译器对C99标准的支持情况

时间:2014-03-29 06:22:02      阅读:517      评论:0      收藏:0      [点我收藏+]

Visual Studio2013终于开始比较良好地支持C99特性了。在此之前,如果用C语言写代码的话,变量名都需要放到函数体的前面部分,代码写起来十分别扭。

而Visual Studio2013中的C编译器已经支持了不少C99标准,让我来为大家盘点一下。

现在仍然不支持的语法特性有:

1、inline关键字:在VC中,仍然需要用微软自己定义的__inline,而尚不支持inline,尽管inline在C++中是支持的。

2、restrict关键字。

3、_Complex与_Imaginary:尽管VS2013的C语言编译器可以用complex.h库,不管这两个关键字不支持。库的实现用的是描述复数的结构体。

4、变长数组

除了上述四点,其它主要特性都予以了支持。下面给出一个示例代码来给出支持特性的描述:

bubuko.com,布布扣
#include <stdio.h>

#define MY_PRINT(...)   printf(__VA_ARGS__)

static __inline int MyGetMax(int x, int y)
{
    return x > y ? x : y;
}

int main(void)
{
    MY_PRINT("%s\n", "Hello, world!");

    int arr[] = { [0] = 100, [2] = 200, [8] = 400 };

    MY_PRINT("The value is: %d\n", arr[2] + arr[3]);

    struct Test
    {
        int x;
        float f;
        _Bool b;
        long long ll;
    
    }test = {.x = 10, .f = -0.5f, .b = 0};

    struct Test t = (struct Test){ .ll = 100LL };

    for (int i = 0; i < test.x; i++)
        t.x += test.x;

    int *p = (int[]){ [1] = t.x, [3] = test.b + test.ll };

    MY_PRINT("The value is: %d\n", p[0] + p[1] + p[2] + p[3]);
}
bubuko.com,布布扣

Visual Studio2013的C语言编译器对C99标准的支持情况,布布扣,bubuko.com

Visual Studio2013的C语言编译器对C99标准的支持情况

原文:http://www.cnblogs.com/zenny-chen/p/3632071.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!