Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <3C02A7F2.8020209@ece.gatech.edu> Date: Mon, 26 Nov 2001 15:37:06 -0500 From: Charles Wilson User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2 X-Accept-Language: en-us MIME-Version: 1.0 To: Marcello CC: cygwin AT cygwin DOT com Subject: Re: sem.h, incompatible tipe for argument 4 of `semctl' References: <20011126194434 DOT 22446 DOT qmail AT web11603 DOT mail DOT yahoo DOT com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit This is a bug in cygipc: http://cygwin.com/ml/cygwin/2001-10/msg00955.html http://cygwin.com/ml/cygwin/2001-10/msg00961.html Unfortunately, I haven't had a chance to fix it yet. In your case, Marcello, just remove the definition for semun from /usr/local/include/sys/sem.h. SUSv2 says that semun should be defined by the application, and not by the system headers (ipc.h & friends). --Chuck Marcello wrote: > Hi, > I'm tring to use semaphores and I'm working with the patch named > 'cygipc' found at the 'ported software' page at the cygin website. > I found an example on the net that seemed to me very easy. > > The problem is that I get the error: > semabinit.c:49: incompatible type for argument 4 of `semctl' > corresponding to the code line: > if( semctl(id, 0, SETVAL, argument) < 0) > > I found on the net some hints to solve this problem, but they couldn't > help me. Can you? > I also attach the code. > Thank you, > > Marcello > > > ------------------------------------------------------------------ > Unix semaphore example > /* semabinit.c - initialize a semaphore for use by programs sema and > semb */ > > #include > #include > #include > #include > > #define KEY (1492) > > void main() > { > int id; /* Number by which the semaphore is known within a program > */ > > union semun { > int val; > struct semid_ds *buf; > ushort * array; > } argument; > > argument.val = 0; > > /* Create the semaphore with external key KEY if it doesn't already > exists. Give permissions to the world. */ > > id = semget(KEY, 1, 0666 | IPC_CREAT); > > /* Always check system returns. */ > > if(id < 0) > { > fprintf(stderr, "Unable to obtain semaphore. "); > exit(0); > } > > /* What we actually get is an array of semaphores. The second > argument to semget() was the array dimension - in our case > 1. */ > > /* Set the value of the number 0 semaphore in semaphore array > # id to the value 0. */ > > if( semctl(id, 0, SETVAL, argument) < 0) > { > fprintf( stderr, "Cannot set semaphore value. "); > } > else > { > fprintf(stderr, "Semaphore %d initialized. ", KEY); > } > } > > > ===== > c:\>ptk > > > > > __________________________________________________ > > __________________________________________________ > Do You Yahoo!? > Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. > http://geocities.yahoo.com/ps/info1 > > -- > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > Bug reporting: http://cygwin.com/bugs.html > Documentation: http://cygwin.com/docs.html > FAQ: http://cygwin.com/faq/ > > -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/