[C++] std::numeric_limits::max() error: '(': illegal token on right side of '::'

本文介绍了一种在C++编程中遇到的max宏冲突问题,该问题导致编译警告和错误。通过取消定义max宏可以有效解决此问题。

#include <limits> 
 
x
= std::numeric_limits<int>::max(); 
 
c
:/.../x.cpp(192) : warning C4003: not enough actual parameters for macro 'max' 
c
:/.../x.cpp(192) : error C2589: '(' : illegal token on right side of '::' 
c
:/.../x.cpp(192) : error C2059: syntax error : '::' 

错误原因:

      包含的另一个头文件中包含了 max() 的宏定义。

 

解决方法:

添加代码:

 

#undef max

 

相关讨论:

 


 

In file included from D:/qt/Tools/mingw492_32/i686-w64-mingw32/include/c++/unordered_map:35:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:29, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/qt/Tools/mingw492_32/i686-w64-mingw32/include/c++/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. #error This file requires compiler and library support for the \ ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:27:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:45:1: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++0x-compat] constexpr Number abs(Number val) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:85:5: warning: identifier 'static_assert' is a keyword in C++11 [-Wc++0x-compat] static_assert(std::is_floating_point<LNumber>::value || std::is_floating_point<RNumber>::value, ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:169:9: warning: identifier 'nullptr' is a keyword in C++11 [-Wc++0x-compat] assert(len_converted != nullptr); ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:76:5: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++0x-compat] optional() noexcept ^ In file included from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:30:0: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell_reference.hpp:267:9: warning: identifier 'decltype' is a keyword in C++11 [-Wc++0x-compat] static_assert(std::is_same<decltype(x.row()), std::uint32_t>::value, "this hash function expects both row and column to be 32-bit numbers"); ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:32:0, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell_type.hpp:38:1: warning: scoped enums only available with -std=c++11 or -std=gnu++11 enum class XLNT_API cell_type ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:33:0, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:40:7: error: expected nested-name-specifier before 'row_t' using row_t = std::uint32_t; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:53:11: error: expected nested-name-specifier before 'index_t' using index_t = std::uint32_t; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:63:12: error: 'index_t' does not name a type static index_t column_index_from_string(const std::string &column_string); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:73:49: error: 'index_t' has not been declared static std::string column_string_from_index(index_t column_index); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:83:22: error: expected ')' before 'column_index' column_t(index_t column_index); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:128:21: error: 'index_t' has not been declared bool operator==(index_t other) const; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:128:10: error: 'bool xlnt::column_t::operator==(int) const' cannot be overloaded bool operator==(index_t other) const; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:123:10: error: with 'bool xlnt::column_t::operator==(int) const' bool operator==(int other) const; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:148:21: error: 'index_t' has not been declared bool operator!=(index_t other) const; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:148:10: error: 'bool xlnt::column_t::operator!=(int) const' cannot be overloaded bool operator!=(index_t other) const; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:143:10: error: with 'bool xlnt::column_t::operator!=(int) const' bool operator!=(int other) const; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:183:36: error: 'index_t' in 'class xlnt::column_t' does not name a type bool operator>(const column_t::index_t &other) const; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:188:37: error: 'index_t' in 'class xlnt::column_t' does not name a type bool operator>=(const column_t::index_t &other) const; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:193:36: error: 'index_t' in 'class xlnt::column_t' does not name a type bool operator<(const column_t::index_t &other) const; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:198:37: error: 'index_t' in 'class xlnt::column_t' does not name a type bool operator<=(const column_t::index_t &other) const; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:243:52: error: 'index_t' in 'class xlnt::column_t' does not name a type friend XLNT_API bool operator>(const column_t::index_t &left, const column_t &right); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:248:53: error: 'index_t' in 'class xlnt::column_t' does not name a type friend XLNT_API bool operator>=(const column_t::index_t &left, const column_t &right); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:253:52: error: 'index_t' in 'class xlnt::column_t' does not name a type friend XLNT_API bool operator<(const column_t::index_t &left, const column_t &right); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:258:53: error: 'index_t' in 'class xlnt::column_t' does not name a type friend XLNT_API bool operator<=(const column_t::index_t &left, const column_t &right); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:268:5: error: 'index_t' does not name a type index_t index; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:271:1: warning: scoped enums only available with -std=c++11 or -std=gnu++11 enum class row_or_col_t : int ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:271:27: warning: scoped enums only available with -std=c++11 or -std=gnu++11 enum class row_or_col_t : int ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:297:8: error: 'hash' is not a class template struct hash<xlnt::column_t> ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/index_types.hpp:298:1: error: explicit specialization of non-template 'std::hash' { ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:30:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/phonetic_run.hpp:38:5: error: 'uint32_t' does not name a type uint32_t start; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/phonetic_run.hpp:39:5: error: 'uint32_t' does not name a type uint32_t end; ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:26:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:50:36: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 exception(const exception &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:55:16: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~exception() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:55:5: error: looser throw specifier for 'virtual xlnt::exception::~exception()' ~exception() override; ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:28:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:26, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/qt/Tools/mingw492_32/i686-w64-mingw32/include/c++/stdexcept:121:13: error: overriding 'virtual std::runtime_error::~runtime_error() throw ()' virtual ~runtime_error() _GLIBCXX_USE_NOEXCEPT; ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:26:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:89:52: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 invalid_parameter(const invalid_parameter &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:94:24: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~invalid_parameter() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:111:56: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 invalid_sheet_title(const invalid_sheet_title &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:116:26: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~invalid_sheet_title() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:134:42: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 invalid_file(const invalid_file &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:139:19: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~invalid_file() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:157:52: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 illegal_character(const illegal_character &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:162:24: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~illegal_character() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:179:52: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 invalid_data_type(const invalid_data_type &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:184:24: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~invalid_data_type() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:201:58: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 invalid_column_index(const invalid_column_index &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:206:27: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~invalid_column_index() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:218:45: error: 'row_t' has not been declared invalid_cell_reference(column_t column, row_t row); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:228:62: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 invalid_cell_reference(const invalid_cell_reference &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:233:29: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~invalid_cell_reference() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:250:52: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 invalid_attribute(const invalid_attribute &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:255:24: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~invalid_attribute() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:272:44: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 key_not_found(const key_not_found &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:277:20: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~key_not_found() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:294:60: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 no_visible_worksheets(const no_visible_worksheets &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:299:28: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~no_visible_worksheets() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:316:60: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 unhandled_switch_case(const unhandled_switch_case &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:321:28: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~unhandled_switch_case() override; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:339:40: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 unsupported(const unsupported &) = default; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/exceptions.hpp:344:18: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 ~unsupported() override; ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:27:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:45:1: error: 'constexpr' does not name a type constexpr Number abs(Number val) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:45:1: note: C++11 'constexpr' only available with -std=c++11 or -std=gnu++11 D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:54:1: error: 'constexpr' does not name a type constexpr typename std::common_type<NumberL, NumberR>::type (max)(NumberL lval, NumberR rval) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:54:1: note: C++11 'constexpr' only available with -std=c++11 or -std=gnu++11 D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:63:1: error: 'constexpr' does not name a type constexpr typename std::common_type<NumberL, NumberR>::type (min)(NumberL lval, NumberR rval) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:63:1: note: C++11 'constexpr' only available with -std=c++11 or -std=gnu++11 D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:80:27: error: no default argument for 'LNumber' int epsilon_scale = 20) // scale the "fuzzy" equality. Higher value gives a more tolerant comparison ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:80:27: error: no default argument for 'RNumber' D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:80:27: error: default template arguments may not be used in function templates without -std=c++11 or -std=gnu++11 D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp: In function 'bool xlnt::detail::float_equals(const LNumber&, const RNumber&, int)': D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:83:11: error: expected nested-name-specifier before 'common_t' using common_t = typename std::common_type<LNumber, RNumber>::type; ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:85:19: error: 'is_floating_point' is not a member of 'std' static_assert(std::is_floating_point<LNumber>::value || std::is_floating_point<RNumber>::value, ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:85:49: error: expected primary-expression before '>' token static_assert(std::is_floating_point<LNumber>::value || std::is_floating_point<RNumber>::value, ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:85:50: error: '::value' has not been declared static_assert(std::is_floating_point<LNumber>::value || std::is_floating_point<RNumber>::value, ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:85:61: error: 'is_floating_point' is not a member of 'std' static_assert(std::is_floating_point<LNumber>::value || std::is_floating_point<RNumber>::value, ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:85:91: error: expected primary-expression before '>' token static_assert(std::is_floating_point<LNumber>::value || std::is_floating_point<RNumber>::value, ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:85:92: error: '::value' has not been declared static_assert(std::is_floating_point<LNumber>::value || std::is_floating_point<RNumber>::value, ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:86:77: error: there are no arguments to 'static_assert' that depend on a template parameter, so a declaration of 'static_assert' must be available [-fpermissive] "Using this function with two integers is just wasting time. Use =="); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:86:77: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:87:76: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 static_assert(std::numeric_limits<EpsilonType>::epsilon() < EpsilonType{1}, ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:98:5: error: 'constexpr' was not declared in this scope constexpr common_t epsilon = static_cast<common_t>(std::numeric_limits<EpsilonType>::epsilon()); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:103:5: error: 'common_t' was not declared in this scope common_t scaled_fuzz = epsilon_scale * epsilon * max(max(xlnt::detail::abs<common_t>(lhs), ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:105:43: error: expected primary-expression before ')' token common_t{1}); // clamp ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:106:20: error: 'scaled_fuzz' was not declared in this scope return ((lhs + scaled_fuzz) >= rhs) && ((rhs + scaled_fuzz) >= lhs); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp: At global scope: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:111:12: error: 'constexpr' does not name a type static constexpr int Excel_Digit_Precision = 15; //sf ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:111:12: note: C++11 'constexpr' only available with -std=c++11 or -std=gnu++11 In file included from D:/qt/Tools/mingw492_32/i686-w64-mingw32/include/c++/cassert:43:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:28, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:27, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp: In member function 'double xlnt::detail::number_serialiser::deserialise(const string&, ptrdiff_t*) const': D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:169:33: error: 'nullptr' was not declared in this scope assert(len_converted != nullptr); ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:27:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:179:9: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat] auto copy_end = std::copy(s.begin(), s.end(), buf); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:179:14: error: 'copy_end' does not name a type auto copy_end = std::copy(s.begin(), s.end(), buf); ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/numeric.hpp:180:54: error: 'copy_end' was not declared in this scope convert_pt_to_comma(buf, static_cast<size_t>(copy_end - buf)); ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp: At global scope: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:57:45: error: 'enable_if' in namespace 'std' does not name a template type template <typename U = T, typename std::enable_if<!std::is_floating_point<U>::value>::type * = nullptr> ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:57:54: error: expected '>' before '<' token template <typename U = T, typename std::enable_if<!std::is_floating_point<U>::value>::type * = nullptr> ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:58:5: error: 'constexpr' does not name a type constexpr bool compare_equal(const U &lhs, const U &rhs) const ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:58:5: note: C++11 'constexpr' only available with -std=c++11 or -std=gnu++11 D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:66:45: error: 'enable_if' in namespace 'std' does not name a template type template <typename U = T, typename std::enable_if<std::is_floating_point<U>::value>::type * = nullptr> ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:66:54: error: expected '>' before '<' token template <typename U = T, typename std::enable_if<std::is_floating_point<U>::value>::type * = nullptr> ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:67:5: error: 'constexpr' does not name a type constexpr bool compare_equal(const U &lhs, const U &rhs) const ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:67:5: note: C++11 'constexpr' only available with -std=c++11 or -std=gnu++11 D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:76:14: error: expected ';' at end of member declaration optional() noexcept ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:76:16: error: 'noexcept' does not name a type optional() noexcept ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:85:28: error: expected ';' at end of member declaration optional(const T &value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_copy_T_noexcept{})) ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:41: error: expected identifier before '(' token #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:85:39: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(const T &value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_copy_T_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:42: error: expected ')' before 'false' #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:85:39: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(const T &value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_copy_T_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:42: error: expected ')' before 'false' #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:85:39: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(const T &value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_copy_T_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:41: error: expected ';' at end of member declaration #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:85:39: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(const T &value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_copy_T_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:42: error: expected unqualified-id before 'false' #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:85:39: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(const T &value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_copy_T_noexcept{})) ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:95:16: error: expected ',' or '...' before '&&' token optional(T &&value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_move_T_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:95:23: error: expected ';' at end of member declaration optional(T &&value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_move_T_noexcept{})) ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:41: error: expected identifier before '(' token #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:95:34: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(T &&value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_move_T_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:42: error: expected ')' before 'false' #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:95:34: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(T &&value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_move_T_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:42: error: expected ')' before 'false' #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:95:34: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(T &&value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_move_T_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:41: error: expected ';' at end of member declaration #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:95:34: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(T &&value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_move_T_noexcept{})) ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:95:25: error: 'int xlnt::optional<T>::noexcept(...)' cannot be overloaded optional(T &&value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_move_T_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:85:30: error: with 'int xlnt::optional<T>::noexcept(...)' optional(const T &value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_copy_T_noexcept{})) ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:42: error: expected unqualified-id before 'false' #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:95:34: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(T &&value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_move_T_noexcept{})) ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:105:35: error: expected ';' at end of member declaration optional(const optional &other) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(copy_ctor_noexcept{})) ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:41: error: expected identifier before '(' token #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:105:46: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(const optional &other) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(copy_ctor_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:42: error: expected ')' before 'false' #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:105:46: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(const optional &other) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(copy_ctor_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:42: error: expected ')' before 'false' #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:105:46: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(const optional &other) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(copy_ctor_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:41: error: expected ';' at end of member declaration #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:105:46: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(const optional &other) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(copy_ctor_noexcept{})) ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:105:37: error: 'int xlnt::optional<T>::noexcept(...)' cannot be overloaded optional(const optional &other) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(copy_ctor_noexcept{})) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:85:30: error: with 'int xlnt::optional<T>::noexcept(...)' optional(const T &value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_copy_T_noexcept{})) ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:43:42: error: expected unqualified-id before 'false' #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false) ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:105:46: note: in expansion of macro 'XLNT_NOEXCEPT_VALUE_COMPAT' optional(const optional &other) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(copy_ctor_noexcept{})) ^ In file included from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/color.hpp:31:0, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/styles/font.hpp:30, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text_run.hpp:29, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/rich_text.hpp:31, from D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/cell/cell.hpp:34, from D:\luoyu\xlnt-master测试有效\xlnt-master\xlnt-master\source\cell\cell.cpp:29: D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:186:28: error: expected '}' before end of line #pragma GCC diagnostic push ^ D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:186:28: error: expected unqualified-id before end of line D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:186:28: error: expected '}' before end of line D:/luoyu/xlnt-master测试有效/xlnt-master/xlnt-master/source/../include/xlnt/utils/optional.hpp:186:28: error: expected declaration before end of line CMakeFiles\xlnt.dir\build.make:54: recipe for target 'CMakeFiles/xlnt.dir/cell/cell.cpp.obj' failed mingw32-make[2]: *** [CMakeFiles/xlnt.dir/cell/cell.cpp.obj] Error 1 CMakeFiles\Makefile2:90: recipe for target 'CMakeFiles/xlnt.dir/all' failed mingw32-make[1]: *** [CMakeFiles/xlnt.dir/all] Error 2 makefile:116: recipe for target 'all' failed mingw32-make: *** [all] Error 2
08-02
<think> 首先,用户的问题是关于 std::numeric_limits<int>::max() 的,他想了解它的使用方法、作用和注意事项。用户提供了几个引用,我需要参考它们。 回顾引用: - 引用[1]:提到如果处理溢出,可以使用 std::numeric_limits<int>::max(),定义一个 long long 变量来比较是否溢出。 - 引用[2]:警告不要用未定义行为测试溢出,如 (n+1)>n,因为有符号数溢出是未定义行为。正确方式是将 n 与 std::numeric_limits<int>::max() 比较。 - 引用[3]:关于清除输入缓冲区,但似乎不相关。 所以,核心是 std::numeric_limits<int>::max(),它在 C++ 中用于获取整数类型的最大值。 我的回答需要: - 使用中文。 - 结构清晰,逐步解决问题。 - 确保真实可靠。 - 在行内数学表达式使用 $...$,独立公式使用 $$...$$。 - 生成相关问题。 - 在引用的段落末尾添加引用标识,如 [^1]。 结构化回答: 1. **介绍**:解释 std::numeric_limits<int>::max() 是什么。 2. **作用**:说明它的用途,如获取整数最大值,处理溢出。 3. **使用方法**:提供简单的代码示例。 4. **注意事项**:基于引用[2],强调不要使用未定义行为测试溢出。 5. **示例代码**:展示如何安全使用。 6. **相关问题**:生成几个相关问题。 确保 LaTeX 语法正确:如果有数学表达式,使用 $...$。例如,讨论数值范围时,可能需要公式。 例如,int 的范围是 $-2^{31}$ to $2^{31}-1$,所以 max() 是 $2^{31}-1$。 代码部分:用户提供了引用中的代码片段,我可以参考。 生成相关问题: - 例如:如何检测整数溢出?std::numeric_limits 的其他用法?等。 参考用户的历史:用户之前的问题是关于字符串到整数的转换和溢出处理,所以上下文是数值处理。 最终回答结构: 1. 简要介绍 std::numeric_limits<int>::max()。 2. 详细解释作用和用法。 3. 注意事项。 4. 代码示例。 5. 相关问题。 </think> ### std::numeric_limits<int>::max() 的使用和含义 `std::numeric_limits<int>::max()` 是 C++ 标准库中的一个模板函数,用于获取 `int` 类型的最大值。它在 `<limits>` 头文件中定义,常用于处理数值边界、溢出检测等场景。下面我将逐步解释其含义、使用方法和注意事项,确保内容真实可靠。 #### 1. **作用和含义** - **作用**:返回 `int` 类型的最大可能值。对于 32 位系统,`int` 通常是 32 位有符号整数,其最大值为 $2^{31}-1$(即 2,147,483,647)。这个值表示 `int` 能存储的最大正数。 - **含义**:在程序中,它用于安全地比较或限制数值,避免整数溢出(例如,当数值超过 $2^{31}-1$ 时,会导致未定义行为或错误)[^1][^2]。 - **通用性**:`std::numeric_limits<T>::max()` 是模板化的,可以用于其他类型(如 `long`、`double`)。例如: - `std::numeric_limits<long>::max()` 返回 `long` 的最大值。 - `std::numeric_limits<double>::max()` 返回 `double` 的最大值。 #### 2. **使用方法** 使用前需包含 `<limits>` 头文件。基本语法如下: ```cpp #include <limits> int max_value = std::numeric_limits<int>::max(); ``` - **示例场景**:检测整数溢出。当处理用户输入或计算时,比较变量是否接近最大值,防止溢出。引用[1] 和 [2] 强调了这种方法的安全性。 ```cpp #include <iostream> #include <limits> #include <climits> // 可选,提供 INT_MAX(与 std::numeric_limits<int>::max() 等价) int main() { int a = 1000000000; // 示例值 int b = 1500000000; // 检测加法是否溢出:使用更大的类型(如 long long)比较 long long sum = static_cast<long long>(a) + b; if (sum > std::numeric_limits<int>::max()) { std::cout << "溢出发生!最大允许值: " << std::numeric_limits<int>::max() << std::endl; } else { int safe_sum = static_cast<int>(sum); std::cout << "安全求和: " << safe_sum << std::endl; } return 0; } ``` - 输出示例:如果 `a + b` 超过 $2^{31}-1$,程序会提示溢出。 #### 3. **注意事项** - **避免未定义行为**:引用[2] 指出,不要用不安全方式测试溢出(如 `(n+1) > n`),因为有符号整数溢出是未定义行为(编译器可能优化掉检查)。始终使用 `std::numeric_limits<int>::max()` 进行比较[^2]。 - **类型转换问题**:当与更大类型(如 `long long`)比较时,确保正确转换类型,避免隐式转换错误。例如: ```cpp long long large_value = ...; // 大数值 if (large_value > std::numeric_limits<int>::max()) { // 处理溢出 } ``` - **返回值处理**:在函数中,如果转换失败(如字符串转整数),避免返回 `0`(可能与正常输入混淆)。引用[1] 建议使用全局变量或修改函数返回值来标识错误[^1]。 - **可移植性**:`std::numeric_limits<int>::max()` 是跨平台的,但数值取决于系统架构(32 位 vs 64 位)。建议优先使用它,而非宏(如 `INT_MAX`),因为它更类型安全。 - **性能**:调用 `std::numeric_limits<int>::max()` 是编译时常量,无运行时开销。 #### 4. **总结** `std::numeric_limits<int>::max()` 是处理整数边界的标准工具,能有效提升程序的健壮性。通过安全比较和溢出检测,可避免未定义行为和数据错误。在实际开发中,结合类型检查和错误处理,能显著提高代码可靠性。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值