我正在尝试使用 libuv 作为事件库来编译hiredis (C++) 附带的示例程序。Redis 的 Windows 兼容版本使用名为 Win32_Interop 的库。
我遇到了两个问题:
libuv 和 Win32_Interop 都定义了 ssize_t,但它们是相互冲突的类型。
libuv 和 Win32_interop 都使用 WinSocks。将程序链接到 ws2_32.lib 会导致重复定义,而不这样做会导致无法解析的外部符号。
我该如何解决这些问题?
有没有特别需要注意的动态自定义类型数组?
我正在尝试创建ConditionParameter的动态数组(下面的定义)
ConditionParameter* m_params;
...
m_params = new ConditionParameter[m_numParams];
Run Code Online (Sandbox Code Playgroud)
但是上面一行的结果只是ConditionParameter类型的一个新对象,其地址存储在m_params中.
struct ConditionParameter
{
ConditionParameter() :
type(OBJ_TYPE_OBJECT),
semantic(OP_SEMANTIC_TYPE_NONE),
instance(NULL),
attrib(ATTRIB_TYPE_NONE),
value(0)
{}
ConditionParameter(const ConditionParameter& other)
{
attrib = other.attrib;
instance = other.instance;
semantic = other.semantic;
type = other.type;
value = other.value;
}
ConditionParameter& operator = (ConditionParameter& other)
{
attrib = other.attrib;
instance = other.instance;
semantic = other.semantic;
type = other.type;
value = other.value;
return *this;
}
ObjectType type;
OperandSemanticType semantic;
Object* instance;
AttributeType attrib;
int value;
};
Run Code Online (Sandbox Code Playgroud)