当我对现有结构中的联合使用这种类型的包装时,当我尝试使用sip安装进行构建时(我将“包装”重命名为“u”,将“测试”重命名为“类型”)会收到以下错误消息:
error: field 'u' has incomplete type 'type_u'
及
note: forward declaration of ‘union type_u’
这里是C++头文件:
struct myType{
enum {CHAR, INT, DOUBLE} tag;
union type_u{
/* tag = CHAR */
char char_value;
/* tag = INT */
int int_value;
/* tag = DOUBLE */
double double_value;
};
type_u u;
void print_my_type() const;
};
这是SIP文件:
struct myType{
enum tag {CHAR, INT, DOUBLE};
struct union_wrapper /PyName=type_u/
{
%TypeHeaderCode
#include <test_struct_union.h>
struct union_wrapper
{
union type_u u;
};
%End
// tag = CHAR
char char_value {
%GetCode
sipPy = PyUnicode_FromString(&(sipCpp->u.char_value));
%End
%SetCode
if (PyUnicode_Check(sipPy))
sipCpp->u.char_value;
else
sipErr = 1;
%End
};
// tag = INT
int int_value {
%GetCode
sipPy = PyLong_FromLong(sipCpp->u.int_value);
%End
%SetCode
if (PyLong_Check(sipPy))
sipCpp->u.int_value;
else
sipErr = 1;
%End
};
// tag = DOUBLE
double double_value {
%GetCode
sipPy = PyFloat_FromDouble(sipCpp->u.double_value);
%End
%SetCode
if (PyFloat_Check(sipPy))
sipCpp->u.double_value;
else
sipErr = 1;
%End
};
};
void print_my_type() const;
};
有人知道如何解决这个问题吗
提前谢谢你
约翰尼
自Sip版本6.0.0以来,支持联合
感谢您快速集成河岸计算
希望手工翻译的方式不再需要了
相关问题 更多 >
编程相关推荐