I learnt from this post here to create helper functions in namespace.
'Helper' functions in C++
//stringhelper.hpp
namespace utility{
static std::string intToString(int integer)
{
std::stringstream sstream;
sstream << integer;
return sstream.str();
}
static void toLowerCase(std::string& y)
{
std::transform(y.begin(), y.end(), y.begin(), (int(*)(int))tolower);
}
}
I include this header but I got the following warning
'void utility::toLowerCase(std::string&)' defined but not used
Yes. I used intToString(int integer) but not toLowerCase(std::string&). I don’t want to see those warning or divide one helper function per header.
Can anyone suggest a good solution? Should I just disable warning? Thank you
You have the option to turn off that warning:
On a function-by-function basis, with GCC, you may define:
This tells GCC that the function is meant to possibly be unused.
See compiler docs for more info on attribute