Commit 8844335d4042306d8ed7a0166cfee984e6bc51c5
Merge pull request #14 from yazevnul/master
Fix Clang -Wsign-conversion and -Wshorten-64-to-32 warnings.
Showing
1 changed file
with
25 additions
and
15 deletions
src/cxxopts.hpp
| ... | ... | @@ -25,6 +25,11 @@ THE SOFTWARE. |
| 25 | 25 | #ifndef CXX_OPTS_HPP |
| 26 | 26 | #define CXX_OPTS_HPP |
| 27 | 27 | |
| 28 | +#if defined(__GNUC__) | |
| 29 | +#pragma GCC diagnostic push | |
| 30 | +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" | |
| 31 | +#endif | |
| 32 | + | |
| 28 | 33 | #include <exception> |
| 29 | 34 | #include <iostream> |
| 30 | 35 | #include <map> |
| ... | ... | @@ -54,7 +59,7 @@ namespace cxxopts |
| 54 | 59 | return icu::UnicodeString::fromUTF8(s); |
| 55 | 60 | } |
| 56 | 61 | |
| 57 | - class UnicodeStringIterator : public | |
| 62 | + class UnicodeStringIterator : public | |
| 58 | 63 | std::iterator<std::forward_iterator_tag, int32_t> |
| 59 | 64 | { |
| 60 | 65 | public: |
| ... | ... | @@ -196,7 +201,7 @@ namespace cxxopts |
| 196 | 201 | |
| 197 | 202 | inline |
| 198 | 203 | String& |
| 199 | - stringAppend(String& s, int n, char c) | |
| 204 | + stringAppend(String& s, size_t n, char c) | |
| 200 | 205 | { |
| 201 | 206 | return s.append(n, c); |
| 202 | 207 | } |
| ... | ... | @@ -244,7 +249,7 @@ namespace cxxopts |
| 244 | 249 | virtual std::string |
| 245 | 250 | get_default_value() const = 0; |
| 246 | 251 | |
| 247 | - virtual std::string | |
| 252 | + virtual std::string | |
| 248 | 253 | get_implicit_value() const = 0; |
| 249 | 254 | |
| 250 | 255 | virtual std::shared_ptr<Value> |
| ... | ... | @@ -410,7 +415,7 @@ namespace cxxopts |
| 410 | 415 | //so that we can write --long=yes explicitly |
| 411 | 416 | value = true; |
| 412 | 417 | } |
| 413 | - | |
| 418 | + | |
| 414 | 419 | inline |
| 415 | 420 | void |
| 416 | 421 | parse_value(const std::string& text, std::string& value) |
| ... | ... | @@ -452,7 +457,7 @@ namespace cxxopts |
| 452 | 457 | { |
| 453 | 458 | parse_value(m_implicit_value, *m_store); |
| 454 | 459 | } |
| 455 | - else | |
| 460 | + else | |
| 456 | 461 | { |
| 457 | 462 | parse_value(text, *m_store); |
| 458 | 463 | } |
| ... | ... | @@ -484,14 +489,14 @@ namespace cxxopts |
| 484 | 489 | |
| 485 | 490 | virtual std::shared_ptr<Value> |
| 486 | 491 | default_value(const std::string& value){ |
| 487 | - m_default = true; | |
| 492 | + m_default = true; | |
| 488 | 493 | m_default_value = value; |
| 489 | 494 | return shared_from_this(); |
| 490 | 495 | } |
| 491 | 496 | |
| 492 | 497 | virtual std::shared_ptr<Value> |
| 493 | 498 | implicit_value(const std::string& value){ |
| 494 | - m_implicit = true; | |
| 499 | + m_implicit = true; | |
| 495 | 500 | m_implicit_value = value; |
| 496 | 501 | return shared_from_this(); |
| 497 | 502 | } |
| ... | ... | @@ -846,8 +851,8 @@ namespace cxxopts |
| 846 | 851 | format_description |
| 847 | 852 | ( |
| 848 | 853 | const HelpOptionDetails& o, |
| 849 | - int start, | |
| 850 | - int width | |
| 854 | + size_t start, | |
| 855 | + size_t width | |
| 851 | 856 | ) |
| 852 | 857 | { |
| 853 | 858 | auto desc = o.desc; |
| ... | ... | @@ -863,7 +868,7 @@ namespace cxxopts |
| 863 | 868 | auto startLine = current; |
| 864 | 869 | auto lastSpace = current; |
| 865 | 870 | |
| 866 | - int size = 0; | |
| 871 | + auto size = size_t{}; | |
| 867 | 872 | |
| 868 | 873 | while (current != std::end(desc)) |
| 869 | 874 | { |
| ... | ... | @@ -932,7 +937,7 @@ OptionAdder::operator() |
| 932 | 937 | const auto& s = result[2]; |
| 933 | 938 | const auto& l = result[3]; |
| 934 | 939 | |
| 935 | - m_options.add_option(m_group, s.str(), l.str(), desc, value, | |
| 940 | + m_options.add_option(m_group, s.str(), l.str(), desc, value, | |
| 936 | 941 | std::move(arg_help)); |
| 937 | 942 | |
| 938 | 943 | return *this; |
| ... | ... | @@ -969,8 +974,8 @@ Options::checked_parse_arg |
| 969 | 974 | { |
| 970 | 975 | throw missing_argument_exception(name); |
| 971 | 976 | } |
| 972 | - } | |
| 973 | - else | |
| 977 | + } | |
| 978 | + else | |
| 974 | 979 | { |
| 975 | 980 | if (argv[current + 1][0] == '-' && value->value().has_implicit()) |
| 976 | 981 | { |
| ... | ... | @@ -1228,7 +1233,7 @@ Options::help_one_group(const std::string& g) const |
| 1228 | 1233 | longest = std::min(longest, static_cast<size_t>(OPTION_LONGEST)); |
| 1229 | 1234 | |
| 1230 | 1235 | //widest allowed description |
| 1231 | - int allowed = 76 - longest - OPTION_DESC_GAP; | |
| 1236 | + auto allowed = size_t{76} - longest - OPTION_DESC_GAP; | |
| 1232 | 1237 | |
| 1233 | 1238 | auto fiter = format.begin(); |
| 1234 | 1239 | for (const auto& o : group->second.options) |
| ... | ... | @@ -1243,7 +1248,7 @@ Options::help_one_group(const std::string& g) const |
| 1243 | 1248 | } |
| 1244 | 1249 | else |
| 1245 | 1250 | { |
| 1246 | - result += toLocalString(std::string(longest + OPTION_DESC_GAP - | |
| 1251 | + result += toLocalString(std::string(longest + OPTION_DESC_GAP - | |
| 1247 | 1252 | stringLength(fiter->first), |
| 1248 | 1253 | ' ')); |
| 1249 | 1254 | } |
| ... | ... | @@ -1299,4 +1304,9 @@ Options::group_help(const std::string& group) const |
| 1299 | 1304 | } |
| 1300 | 1305 | |
| 1301 | 1306 | } |
| 1307 | + | |
| 1308 | +#if defined(__GNU__) | |
| 1309 | +#pragma GCC diagnostic pop | |
| 1310 | +#endif | |
| 1311 | + | |
| 1302 | 1312 | #endif //CXX_OPTS_HPP | ... | ... |