深秋的落叶
ARM && Linux kernel
posts - 26,  comments - 26,  trackbacks - 1

======================================================

一、error: invalid operands to binary -

int modify_passwd(...){

  int len = 1024;

  unsigned char *pbuf = NULL;

  char *p = NULL;

 

  ......

  pbuf  = (unsigned char *)malloc(len+sizeof(int));

  if(NULL == pbuf){...}

  p = strchr(pbuf, ':');

  if(p) bytes = p - pbuf;

  ......

}

/*

 * [root@localhost zg.a]# gcc passwd.c modify_passwd.c validate_user.c -I. -o videocollect -DMYDEBUG -Wall -g -lcrypto  
 * modify_passwd.c: In function `modify_passwd':
 * modify_passwd.c:89: error: invalid operands to binary -

 * 错误原因:p和pbuf类型不一致。

 * 解决方案:

 *  1、修改p的定义为: unsigned char *p = NULL;

 *  2、修改"p - pbuf"为: p - (char *)pbuf

 ********************************************************/

posted on 2009-11-19 12:48 刘伟_luvi 阅读(...) 评论(...) 编辑 收藏