免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 9988 | 回复: 10
打印 上一主题 下一主题

请教:linux下怎么编译shmget呢? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-10 11:17 |只看该作者 |倒序浏览
操作系统:redhat
头文件:#include    <sys/ipc.h>
            #include    <sys/shm.h>

代码:shmid = shmget( key , UUSER , IPC_ALLOC|0666 )
编译报错:`IPC_ALLOC' undeclared

但是如果将IPC_ALLOC|0666 改成IPC_CREAT|0666 编译就顺利通过,现请教IPC_ALLOC是什么头文件里定义的呢?和IPC_CREAT不是一个文件里么?

在unix下编译也是顺利通过的。

[ 本帖最后由 llzh 于 2007-3-10 11:22 编辑 ]

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
2 [报告]
发表于 2007-03-10 11:20 |只看该作者
头文件怎么加的?
linux下没有这个东西

[ 本帖最后由 cjaizss 于 2007-3-10 11:27 编辑 ]

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
3 [报告]
发表于 2007-03-10 11:28 |只看该作者
在UNIX下编译成功?哪个UNIX下?linux也算UNIX,反正真正的UNIX都死了。

论坛徽章:
0
4 [报告]
发表于 2007-03-10 11:35 |只看该作者
sco unix
aix unix

论坛徽章:
0
5 [报告]
发表于 2007-03-10 11:44 |只看该作者
原帖由 cjaizss 于 2007-3-10 11:28 发表
在UNIX下编译成功?哪个UNIX下?linux也算UNIX,反正真正的UNIX都死了。


也不能这样说嘛,ls说一下那些才是真正的unix

论坛徽章:
0
6 [报告]
发表于 2007-03-10 15:14 |只看该作者

回复 5楼 zwylinux 的帖子

ESR wrote an article in response to SCO's complaint against IBM for alledgedly `devaluing' its version of the UNIX operating system, explaining how `Unix' is defined in his view, though.

论坛徽章:
0
7 [报告]
发表于 2007-03-19 19:47 |只看该作者
我和楼主遇到了一样的问题
linux下,IPC_CREAT和IPC_EXCL是在bits/ipc.h中定义的
没有IPC_ALLOC

网上找到的:
Hi,

I am trying to compile a C code written for AIX Unix on Linux environment RH8.
The code has following function call:

msgq_id = msgget(ipc_key, IPC_ALLOC | IPC_R | IPC_W);

On AIX, ipc.h file contains definition of these parameters as follows:

/* Common ipc_perm mode Definitions. */
#define IPC_ALLOC 0100000 /* entry currently allocated */
#define IPC_R 0000400 /* read or receive permission */
#define IPC_W 0000200 /* write or send permission */

But, on Linux, ipc.h does not contain any such definition. Hence, the C program is not getting compiled, giving error "`IPC_ALLOC' undeclared (first use in this function)".

I need to find a parallel for this function call (i.e. for IPC_ALLOC, IPC_R, IPC_W) on Linux.

Please help guys...

Thanks in advance,
Bhooshan

论坛徽章:
0
8 [报告]
发表于 2007-03-19 19:52 |只看该作者
man shmget linux 下不支持  IPC_ALLOC
      The value shmflg is composed of:

       IPC_CREAT   to create a new segment. If this flag  is  not  used,  then
                   shmget()  will  find the segment associated with key, check
                   to see if the user has  permission  to  receive  the  shmid
                   associated  with the segment, and ensure the segment is not
                   marked for destruction.

       IPC_EXCL    used with  IPC_CREAT  to  ensure  failure  if  the  segment
                   exists.

       mode_flags (lowest 9 bits)
                   specifying the permissions granted to the owner, group, and
                   world.  Presently, the execute permissions are not used  by
                   the system.

论坛徽章:
0
9 [报告]
发表于 2008-04-21 16:37 |只看该作者

回复 #1 llzh 的帖子

我把IPC_ALLOC|0666 改成IPC_CREAT|0666 就能编译过,而且结果也正确,感觉好像都整合成CREAT了

论坛徽章:
0
10 [报告]
发表于 2008-04-21 16:51 |只看该作者
没有用过IPC_ALLOC

不过IPC_CREAT确实用过,确实有创建IPC 的效果
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP