Skip to content

Commit

Permalink
fix tars2cpp compiler warning when field in struct is float or double
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanshudong committed Jun 18, 2024
1 parent 37534fa commit 5deae59
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tools/tars2cpp/tars2cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,25 @@ string Tars2Cpp::writeTo(const TypeIdPtr& pPtr) const

if (mPtr || vPtr)
{
s << TAB << "if (" << pPtr->getId() << ".size() > 0)" << endl;
s << TAB << "if (!" << pPtr->getId() << ".empty())" << endl;
}
else
{
//bool类型, 都传输, 为了避免之前调整bool缺省值的bug
if(!(bPtr && bPtr->kind() == Builtin::KindBool))
{
s << TAB << "if (" << pPtr->getId() << " != " << sDefault << ")" << endl;
if(bPtr->kind() == Builtin::KindFloat)
{
s << TAB << "if (!tars::TC_Common::equal(" << pPtr->getId() << ", (float)" << sDefault << "))" << endl;
}
else if(bPtr->kind() == Builtin::KindDouble)
{
s << TAB << "if (!tars::TC_Common::equal(" << pPtr->getId() << ", (double)" << sDefault << "))" << endl;
}
else
{
s << TAB << "if (" << pPtr->getId() << " != " << sDefault << ")" << endl;
}
}
else
{
Expand Down

0 comments on commit 5deae59

Please sign in to comment.