【发布时间】:2012-03-29 11:37:45
【问题描述】:
如果有一个函数具有非 void 返回值但在其定义中不包含 return 语句,是否有人知道 gcc/g++ 选项会生成错误/警告?
例如:
int add(int a, int b)
{
a+b;
}
非常感谢!
【问题讨论】:
标签: c++ gcc compiler-construction compiler-errors compiler-warnings
如果有一个函数具有非 void 返回值但在其定义中不包含 return 语句,是否有人知道 gcc/g++ 选项会生成错误/警告?
例如:
int add(int a, int b)
{
a+b;
}
非常感谢!
【问题讨论】:
标签: c++ gcc compiler-construction compiler-errors compiler-warnings
-Wreturn-type。它由-Wall 启用(您应该始终与-Werror -Wextra 一起运行)。
【讨论】:
-Wextra,根据个人喜好-Werror
-Wall -Wextra -Werror。
-Weffc++。