-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
开启-Werror,-Wreturn-type,会存在编译报错:
emock/include/emock/ApiHookMocker.h:104:1: error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type]
104 | }
| ^
问题原因:
template <>
inline InvocationMockBuilderGetter mockAPI<const char>(const std::string&, const char* matcher)
{
std::string m(matcher);
std::string returnType("void");
std::string::size_type from = m.find('{');
if(from != std::string::npos) {
std::string::size_type to = m.find('}', from);
returnType = m.substr(from + 1, to - from - 1);
m = m.replace(from, to - from + 1, "");
}
from = m.find('#');
std::string callingConv;
if(from != std::string::npos) {
std::string::size_type to = m.find('#', from);
callingConv = m.substr(from + 1, to - from - 1);
m = m.replace(from, to - from + 1, "");
}
else {
from = m.find('!');
if(from != std::string::npos) {
callingConv = "EMOCK_API";
m = m.erase(from, 1);
}
}
RT_BRANCH(void)
else INTERGRAL_RT_BRANCH(char)
else INTERGRAL_RT_BRANCH(short)
else INTERGRAL_RT_BRANCH(int)
else INTERGRAL_RT_BRANCH(long)
else INTERGRAL_RT_BRANCH(long long)
else RT_BRANCH(float)
else RT_BRANCH(double)
else RT_BRANCH(long double)
else EMOCK_REPORT_FAILURE(std::string("Unsupported return type {").append(returnType.c_str()).append("}, use EMOCKX(")
.append(returnType.c_str()).append(", \"").append(m.c_str()).append("\") instead.").c_str());
return InvocationMockBuilderGetter(nullptr, nullptr);//缺少这句。
}我只是默认空实现了一个。
Metadata
Metadata
Assignees
Labels
No labels