gcc options: warning on non-void functions without a return statement

佐手、 提交于 2019-11-30 17:11:10

问题


Does anyone know a gcc/g++ option that generates an error/warning if there's a function that has a non-void return value but doesn't contain a return statement in its definition?

e.g.:

int add(int a, int b)
{
    a+b;
}

Many thanks in advance!


回答1:


-Wreturn-type. It's enabled by -Wall (which you should always be running with, along with -Werror -Wextra).



来源:https://stackoverflow.com/questions/9924570/gcc-options-warning-on-non-void-functions-without-a-return-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!