zoukankan      html  css  js  c++  java
  • Visual Studio2013的C语言编译器对C99标准的支持情况

    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、变长数组

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

    #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
    ", "Hello, world!");
    
        int arr[] = { [0] = 100, [2] = 200, [8] = 400 };
    
        MY_PRINT("The value is: %d
    ", 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
    ", p[0] + p[1] + p[2] + p[3]);
    }
  • 相关阅读:
    关于用网线连开发板和电脑网卡问题
    信号量同步编程
    信号量互斥编程
    信号通讯
    有名管道通讯
    dell 燃 7000 系列 7460/7560 禁用触控板 触摸板
    关于错误node_modules/@types/jasmine/index.d.ts(39,52): error TS1005: '=' expected.
    环境配置,nodejs,cnpm,git,webstorm,powershell,
    gitflow工作流
    <问题汇总>ionic2开发app
  • 原文地址:https://www.cnblogs.com/zenny-chen/p/3632071.html
Copyright © 2011-2022 走看看