C问:没有警告? [英] C question: no warning?

查看:139
本文介绍了C问:没有警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

main()
{
  printf("Hello World.");
}


$ b <返回类型为'int'

Why does no warning is produced in gcc compiler even though we declare main() with return type 'int'

推荐答案

因为你不使用-Wall标志。当你这样做,你应该得到:

Because you're not using the -Wall flag. When you do, you should get:

foo.c:1: warning: return type defaults to ‘int’
foo.c: In function ‘main’:
foo.c:1: warning: implicit declaration of function ‘printf’
foo.c:1: warning: incompatible implicit declaration of built-in function ‘printf’
foo.c:1: warning: control reaches end of non-void function

这篇关于C问:没有警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆