summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2024-12-11 19:20:51 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2024-12-11 21:36:07 +0100
commit5aba94355ec638c6f8612f86be309ed684979ae3 (patch)
tree5335799f24513511598bd1eb2e85dafdb47c78e0
parent9ff20ef857429619267e3f156a4f81ad9e1eb8c1 (diff)
Fix warnings.fix_warnings
-rw-r--r--getoptpp.hpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/getoptpp.hpp b/getoptpp.hpp
index 92f8e82..a9791d1 100644
--- a/getoptpp.hpp
+++ b/getoptpp.hpp
@@ -116,14 +116,14 @@ class Options {
if(index >= (int)options.size()) {
break;
}
- auto const & opt = options.at(index);
- std::string args;
+ auto const & opt = options.at(static_cast<std::size_t>(index));
+ std::string _args;
switch(opt.has_arg) {
case required_argument:
- args = "<x>";
+ _args = "<x>";
break;
case optional_argument:
- args = "[x]";
+ _args = "[x]";
break;
case no_argument:
default:
@@ -133,11 +133,12 @@ class Options {
std::string option_str;
if(opt.val >= '!' && opt.val <= '~')
{
- option_str = " -" + std::string(1, opt.val) + ", --" + opt.name + " " + args;
+ auto c = static_cast<char>(opt.val);
+ option_str = " -" + std::string(1, c) + ", --" + opt.name + " " + _args;
}
else
{
- option_str = " --" + std::string(opt.name) + " " + args;
+ option_str = " --" + std::string(opt.name) + " " + _args;
}
std::string padding;
@@ -158,8 +159,8 @@ class Options {
{
if((c == '\n') || (i > column_width && (c == ' ' || c == '\t')))
{
- std::string padding(width, ' ');
- std::cout << '\n' << padding;
+ std::string _padding(width, ' ');
+ std::cout << '\n' << _padding;
i = width;
continue;
}
@@ -172,7 +173,7 @@ class Options {
}
private:
- std::size_t num_flags{};
+ int num_flags{};
std::vector<option> options{};
std::deque<std::string> names{};
std::vector<std::string> help_texts{};