首页 > 其他 > 详细

编译选项的使用

时间:2018-05-27 16:14:32      阅读:199      评论:0      收藏:0      [点我收藏+]

1.禁止隐式声明

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

eg: test.c
int main(int argc, char *argv[])
{
    char *pstr = "hello nihao";
    printf("l pstr=%s\n", 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\n", 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\n", pstr);
  ^
test.c:5:2: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
cc1: some warnings being treated as errors

 

编译选项的使用

原文:https://www.cnblogs.com/hellokitty2/p/9096272.html

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