zoukankan      html  css  js  c++  java
  • 编译选项的使用

    1.禁止隐式声明

    -Werror=implicit-function-declaration 编译选项中加了这个,隐式声明不过,报error而不是warning了

    eg: test.c
    int main(int argc, char *argv[])
    {
        char *pstr = "hello nihao";
        printf("l pstr=%s
    ", pstr);
    }
    
    [ubuntu @tmp]$ gcc test.c -o pp
    test.c: In function ‘main’:
    test.c:5:2: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
      printf("l pstr=%s
    ", pstr);
    
    
    [ubuntu @tmp]$ gcc test.c -Werror=implicit-function-declaration  -o pp
    test.c: In function ‘main’:
    test.c:5:2: error: implicit declaration of function ‘printf’ [-Werror=implicit-function-declaration]
      printf("l pstr=%s
    ", pstr);
      ^
    test.c:5:2: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
    cc1: some warnings being treated as errors

    2. __unused 加载参数后面表示参数不使用,就不会报参数没有使用的警告了

    int main(int argc __unused, char *argv[] __unused) 
    {
        return 0;      
    }
  • 相关阅读:
    python面试题目
    Mysql综合练习作业50题
    django rest framework自定义返回格式
    mongodb副本集部署
    celery学习笔记
    npm学习笔记
    awk学习笔记
    SaltStack grains学习笔记
    nginx + uwsgi + centos7部署django
    Reids集群安装
  • 原文地址:https://www.cnblogs.com/hellokitty2/p/9096272.html
Copyright © 2011-2022 走看看