|
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/sem.h>
#include<stdio.h>
#include<iostream>
#define SEM_PATH "./my_sem"
using namespace std;
int main()
{
union semun arg;
int flag1,flag2;
flag1=IPC_CREAT|IPC_EXCL|00666;
flag2=IPC_CREAT|00666;
key_t key=ftok(SEM_PATH,'a');
if(key<0)
{
cout<<"ftok error!"<<endl;
return -1;
}
int semid=semget(key,5,flag1);
if(semid<0)
if(errno==EEXIST)
semid=semget(key,5,flag2);
cout<<"ok"<<endl;
return 0;
}
错误是这样的:10:aggregate "semun arg" has incomplete type and cannot be defined
望高手们帮帮忙啊,小弟将感激不尽!!!! |
|