delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/11/26/15:04:13

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <20011126194434.22446.qmail@web11603.mail.yahoo.com>
Date: Mon, 26 Nov 2001 11:44:34 -0800 (PST)
From: Marcello <piteko AT yahoo DOT com>
Subject: sem.h, incompatible tipe for argument 4 of `semctl'
To: cygwin AT cygwin DOT com
MIME-Version: 1.0

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019