Mail Archives: cygwin/2001/11/26/15:37:45
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 <sys/types.h>
> #include <sys/ipc.h>
> #include <sys/sem.h>
> #include <stdio.h>
>
> #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/
- Raw text -