zoukankan      html  css  js  c++  java
  • 检测 gcc 是否支持 C99 标准的方法

    一般来说 gcc 3.0 以上都是支持 C99 的

    但是编译的时候得加上 -std=c99

    检测 gcc 是否支持 C99 方法,新建 c99.c 文件,内容如下

    #include <stdio.h>
    
    int main(void) {
    #ifdef __STDC__
         printf("%s
    ", "stardard C");
    #endif
    #ifdef __STDC_VERSION__
         // 正确输出结果应该是 long 型,
         // 这里本应该用 %ld, 但命令行运行不会返回提示而需要手动运行一次;
         // 故用 %d 让其警告而不用再次运行编译后程序即可查看结果
         printf("%d
    ", __STDC_VERSION__);
    #endif
         return 0;
    }



    然后命令行执行:

    gcc -std=c99 -o c99 c99.c -Wall
    1
    终端返回结果如下:

    c99.c:12:21: warning: format specifies type 'int' but the argument has type
          'long' [-Wformat]
         printf("%d
    ", __STDC_VERSION__);
                 ~~     ^~~~~~~~~~~~~~~~
                 %ld
    <built-in>:327:26: note: expanded from here
    #define __STDC_VERSION__ 199901L
                             ^~~~~~~
    1 warning generated.
    


    执行 c99 程序返回:

    stardard C
    199901

  • 相关阅读:
    老男孩Python全栈开发(92天全)视频教程 自学笔记08
    datagrid---columns列
    easyui---datagrid
    easyui---layout实战
    easyui---layout布局
    easyui---表单验证
    easyui---form表单_validatebox验证框
    easyui---easyloader.js
    easyui---基础组件:dialog
    easyui---基础组件:window
  • 原文地址:https://www.cnblogs.com/CodeWorkerLiMing/p/12007374.html
Copyright © 2011-2022 走看看