Vis*_*hnu 0 c struct compiler-errors
我在C中为以下行获取错误"从类型'int'中分配类型'memstruct'时出现的不兼容类型:
result1 = getValueFromBind(interpret(t->ptr1));.
Run Code Online (Sandbox Code Playgroud)
result1和function的声明如下:
memstruct result1;
memstruct getValueFromBind(memstruct bind);
Run Code Online (Sandbox Code Playgroud)
此外,memstruct函数定义如下:typedef union Constant {int intval; char*strval; }不变; typedef struct memstruct {int type; 恒定价值; } memstruct;
编辑:getValueFromBind函数在简单检查后返回bind或NULL.解释返回memstruct.此外,错误显示在C中的分配.
以下是极简主义的例子(@gsamaras):http://ideone.com/Rb8ZCd
当dsh回答它时,解决了程序中的错误