xlnt icon indicating copy to clipboard operation
xlnt copied to clipboard

如果你不能在windows GUI程序中使用xlnt。If you can't use xlnt in your windows GUI application。

Open JKwarn opened this issue 3 years ago • 1 comments

确保 #include <windows.h> 之前 #include "xlnt/xlnt.hpp" #pragma comment(lib, "xlnt.lib")

原因:windows.h中的宏覆盖了同名函数。

举例: 文件 xlnt\utils\numeric.hpp 有函数如下

template <typename NumberL, typename NumberR>
constexpr typename std::common_type<NumberL, NumberR>::type max(NumberL lval, NumberR rval)

在minwindef.h中,有同名的宏 max 如下

// in minwindef.h
#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif

由于宏的优先级高于函数定义。因此,上列函数模板被宏替换为

template <typename NumberL, typename NumberR>
constexpr typename std::common_type<NumberL, NumberR>::type (((a) > (b)) ? (a) : (b))(NumberL lval, NumberR rval)

导致编译失败。

JKwarn avatar Jul 20 '21 02:07 JKwarn

非常感谢

dahaigj avatar Jul 22 '21 10:07 dahaigj