ERROR:invalid operands to binary -
2010-03-26 18:04
393 查看
ERROR:invalid operands to binary - (二元减法运算的操作数无效。)
代码如下:
编译,提示错误"invalid operands to binary -"
二元减法运算的操作数无效。
检查后发现,pchg_rule为char *, chgrule_info->chg_rule为unsigned char[],不能直接进行减法运算。
修改如下:
i = (unsigned short)(pchg_rule-(char *)chgrule_info->chg_rule);
问题解决。
代码如下:
... typedef PACKED struct { unsigned char chg_rule[MMIPT_MAX_CHG_RULE_LIST]; ... }MMIPT_CHG_RULE_T; void Example(...) { ... char *pchg_rule = NULL; MMIPT_CHG_RULE_T *chgrule_info; ... for(i = (unsigned short)(pchg_rule- chgrule_info->chg_rule); i < MMIPT_MAX_CHG_RULE_LIST; i++) ... } ....
编译,提示错误"invalid operands to binary -"
二元减法运算的操作数无效。
检查后发现,pchg_rule为char *, chgrule_info->chg_rule为unsigned char[],不能直接进行减法运算。
修改如下:
i = (unsigned short)(pchg_rule-(char *)chgrule_info->chg_rule);
问题解决。
相关文章推荐
- error: invalid operands of types 'int()' and 'int' to binary 'operator%'
- 6410_io_drv.c: error: invalid operands to binary << (have 'char *' and 'int') 错误处理
- iPhone实例学习之iphone sdk2.0 miss和invalid operands to binary问题
- gcc编译出现 invalid operands to binary -的解决方法
- Swift Compiler Error Binary oprator '+' cannot be applied to operands of type 'UInt16' and 'UInt8'
- Invalid operands to binary expression ('double' and 'double’)
- 【iOS】swift-Binary operator '|' cannot be applied to two UIViewAutoresizing operands
- Error 1 Operator '+' cannot be applied to operands of type 'string' and 'method group'
- Swift中推送通知设置:Binary operator '|' cannot be applied to two UIUserNotificationType operands 错误解决
- error: invalid operands of types ‘double’ and ‘double’ to binary ‘operator^’
- Read and Write compressed data to a binary file using ASP.NET
- The connection to adb is down, and a severe error has occured.
- The connection to adb is down, and a severe error has occured
- The connection to adb is down, and a severe error has occured
- error: invalid conversion from ‘void (*)()’ to ‘void (*)(int)’
- 【error】VS2010 LINK1123: failure during conversion to COFF: file invalid or corrupt
- android关于The connection to adb is down, and a severe error has occured.这个问题的解决办法
- [转]Error: "SQL BPA command line has encountered a problem and needs to close"
- 报错:The connection to adb is down, and a severe error has occured.
- An error was encountered. Please return to the previous page and try again.