作者: 世俗孤岛 时间: 2015-3-1 17:28
该程序运行时有两个警告:1.return type of 'main' is not 'int' [-Wmain-return-type]
原因:c/c++中并没有定义 void main() 这个函数,而是定义了int main( void ) 和 int main( int argc, char *argv[] ),所以编译器会发出警告(仍可以运行)。
操作系统是根据main()的返回值来决定接下来做什么的。可以自定义 void fun() 函数,这会涉及到其他东西,如:函数参数、指针、值传递、函数调用
等,楼主可以学习相关知识。
2.comparison of unsigned expression >= 0 is always true [-Wtautological-compare //这个警告是致命的,会造成程序异常