-1

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.

user3068597
  • 13
  • 1
  • 5

1 Answers1

8

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;
unwind
  • 391,730
  • 64
  • 469
  • 606
  • Specifically if your `row->offset` value is in `byte`s then you need your pointers to be working in `byte` units. – benjymous Mar 06 '14 at 15:34