-
Notifications
You must be signed in to change notification settings - Fork 283
Closed
Description
I get a warning about sign compare:
argparse.hpp: In function ‘std::ostream& argparse::operator<<(std::ostream&, const Argument&)’:
argparse.hpp:686:53: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const std::__cxx11::basic_string<char>::size_type’ {aka ‘const long unsigned int’} [-Wsign-compare]
686 | while ((pos = argument.m_help.find('\n', prev)) != std::string::npos) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
This is because at line 680 auto pos is recognized as signed int instead of an unsigned type.
I recommend marking the values of pos and prev as unsigned or setting their type explicitly to size_t:
auto pos = 0u;
auto prev = 0u; size_t pos = 0;
size_t prev = 0;See also the comments in this PR: #276 (comment)
Metadata
Metadata
Assignees
Labels
No labels