I am building an application that will used shared memory and I have tried to compile the attached source file. I have version 3.4.4-3 of the gcc compiler and appropriate support libraries.
If I use a simple gcc command it complains $ gcc -Wall -Werror writer.c writer.c: In function `main': writer.c:34: warning: implicit declaration of function `shm_open' writer.c:85: warning: implicit declaration of function `shm_unlink' ------------------------------------------------------- Source file ----------------------------------------------------- /* ** These examples use semaphores to ensure that writer and reader ** processes have exclusive, alternating access to the shared-memory region. */ /********** writer.c ***********/ #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <semaphore.h> #include <errno.h> #include <sys/types.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/fcntl.h> char shm_fn[] = "my_shm"; char sem_fn[] = "my_sem"; /**** WRITER ****/ int main(){ caddr_t shmptr; unsigned int mode; int shmdes, index; sem_t *semdes; int SHM_SIZE; mode = S_IRWXU|S_IRWXG; /* Open the shared memory object */ if ( (shmdes = shm_open(shm_fn,O_CREAT|O_RDWR|O_TRUNC, mode)) == -1 ) { printf("shm_open failure"); exit(1); } /* Preallocate a shared memory area */ SHM_SIZE = 4096; if(ftruncate(shmdes, SHM_SIZE) == -1){ printf("ftruncate failure"); exit(1); } if((shmptr = mmap(0, SHM_SIZE, PROT_WRITE|PROT_READ, MAP_SHARED, shmdes,0)) == (caddr_t) -1){ printf("mmap failure"); exit(1); } /* Create a semaphore in locked state */ semdes = sem_open(sem_fn, O_CREAT, 0644, 0); if(semdes == (void*)-1){ printf("sem_open failure"); exit(1); } /* Access to the shared memory area */ for(index = 0; index < 100; index++){ printf("write %d into the shared memory shmptr[%d]\n", index*2, index); shmptr[index]=index*2; } /* Release the semaphore lock */ sem_post(semdes); munmap(shmptr, SHM_SIZE); /* Close the shared memory object */ close(shmdes); /* Close the Semaphore */ sem_close(semdes); /* Delete the shared memory object */ shm_unlink(shm_fn); exit(0); return 0; } ------------------------------------------------------- End Source file ----------------------------------------------------- I tried searching for shm_open in my version of the /cygwin/usr/include directory and did not find either the shm_open or shm_unlink prototypes defined. In looking through the FAQ I came across this link http://cygwin.com/ml/cygwin-cvs/2007-q1/msg00071.html which suggests to me that I need an update on my header files and perhaps the dll. Is this update available now and if not, when will it be? How do I acquire these changes? Thanks Don Marquardt 604 273 5131 X 810