All pastes #399796 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-03-18 08:12 UTC
rendered paste body
hplib.h: En la función 'waitSemaphore':
hplib.h:16: error: la variable 'opWait' tiene inicializador pero de tipo de dato incompleto
hplib.h:16: aviso: exceso de elementos en el inicializador de struct
hplib.h:16: aviso: (cerca de la inicialización de 'opWait')
hplib.h:16: aviso: exceso de elementos en el inicializador de struct
hplib.h:16: aviso: (cerca de la inicialización de 'opWait')
hplib.h:16: aviso: exceso de elementos en el inicializador de struct
hplib.h:16: aviso: (cerca de la inicialización de 'opWait')
hplib.h:16: error: no se conoce el tamaño de almacenamiento de 'opWait'
make: *** [main.o] Error 1



-----------------hplib.h---------------------
#include <stdlib.h>

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>

#define	KEY			(key_t)1000
#define POLICIES	0666

// Manejo de semáforos
int createSemaphore() {
	return semget(KEY, 1, POLICIES | IPC_CREAT);
}

void waitSemaphore(int semid) {
	struct sembuf opWait = {0, -1, 0};
	
	semop(semid, &opWait, 1);
}

// Manejo del segmento de memoria compartida
int createSharedSegment(int size) {
	return shmget(KEY, size, POLICIES | IPC_CREAT);
}

void* assignSharedSegment(int id) {
	return (void*)shmat(id, NULL, NULL);
}

int unassignSharedSegment(const void* address) {
	return shmdt(address);
}