Pregunta

I am getting the unknown size error from the code below,

    atmel_device_info_t *info;

    int *ptr = row->offset + (void *) info

It is a casting problem, what should I do to fix the error? thank you for your help.

¿Fue útil?

Solución

You cannot portably do arithmetic with a void * pointer. This makes sense, since it's a pointer to an unknown type of data, that data has no intrinsic size. The size of the pointed-to data is a central part of doing arithmetic.

usually a "byte" pointer works:

int *ptr = (int *) ((unsigned char *) info + row->offset);

The above assumes that row->offset is a byte offset, not an int offset. If you want the latter, cast accordingly:

int *ptr = (int *) info + row->offset;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top