+ -
当前位置:首页 → 问答吧 → 关于shmat的返回值

关于shmat的返回值

时间:2010-07-26

来源:互联网

出错返回-1,我将返回值与-1比较会出现警告,怎么去掉这个警告?

作者: _cer   发布时间: 2010-07-26

是否是unsigned问题?

作者: zhangsuozhu   发布时间: 2010-07-26

我的意思是这样的
  1. ret = shmat(shm_id, 0, 0);
  2. if (ret == -1) {   // warning: comparison between pointer and integer
  3.     return ;
  4. }
复制代码

作者: _cer   发布时间: 2010-07-26

shmat 返回啥类型?

作者: zhangsuozhu   发布时间: 2010-07-26

回复 zhangsuozhu


    RETURN VALUES
     Upon successful completion, shmat() returns the data segment
     start address of the attached shared memory segment; shmdt()
     returns 0. Otherwise, -1 is returned, the shared memory seg-
     ment  is  not  attached,  and  errno  is set to indicate the
     error.

作者: _cer   发布时间: 2010-07-26

本帖最后由 zhangsuozhu 于 2010-07-26 17:49 编辑
  1.    
  2.    ret = shmat(shm_id, 0, 0);
  3.    if (ret == (void *)-1) {   // 转一下-1就行了吧
  4.         return ;
  5.    }
复制代码

作者: zhangsuozhu   发布时间: 2010-07-26



QUOTE:
zhangsuozhu 发表于 2010-07-26 17:45




    OK,谢谢了

作者: _cer   发布时间: 2010-07-26

相关阅读 更多