[C con Clase] memoria compartida y estructuras

nree p_westermani en hotmail.com
Mar Mayo 20 10:31:56 CEST 2008


Hola, 

tengo un problemilla, que espero que alguien me pueda resolver. Me gustaria saber como crear una estructura compartida en memoria. Hasta ahora he usado algunos chars sin problema pero no se como hacerlo con una estructura que yo he creado, os pongo parte de mi codigo pero asi no va

****************************************************************************

if ((shmid7 = shmget (key7, sizeof(unsigned char), 0666 | IPC_CREAT)) == -1)
{
	perror ("shmget");
	return (-1);
}
if ((shmid8 = shmget (key8, sizeof(childrenControl), 0666 | IPC_CREAT)) == -1)
{
	perror ("shmget");
	return (-1);
}

rtc_day_of_week = (unsigned char *) shmat(shmid7, 0, 0);
	if (rtc_day_of_week == (unsigned char *) -1) {
        perror("shmat");
        exit(-1);
    }
cc = (childrenControl *) shmat(shmid8, 0, 0);
	if (cc == (childrenControl *) -1) {
		perror("shmat");
		exit(-1);
	}

.........................

if ((rtc_day_of_week = (unsigned char *)shmat (shmid7, (void *)0, 0)) == (unsigned char *) -1)
{
	perror("shmat");
	return (1);
}
if ((cc = (childrenControl *)shmat (shmid7, (void *)0, 0)) == (childrenControl *) -1)
{
	perror("shmat");
	return (1);
}

*****************************************************************

despues de haber hecho esto puedo usar las variables tipo char de este modo

*rtc_day_of_week = .......

pero con  *cc = .......

me dice

error: argumento de tipo inválido de ‘unary *’

alguna idea????

gracias...


Más información sobre la lista de distribución Cconclase