'void *' : unknown size

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to do some pointer manipulation and can not avoid using void * as
the type declaration. I get this error message : error C2036 : 'void *' :
unknown size though. Is there a compiler option or a way to tell the compiler
the size of void * to avoid this?

On a side note, when using W2003, I have this site defined as a trusted site
but the "new question" dialog is blocked as a popup (I had to go to a W2000
distribution). Popup blocked is disabled for Trusted sites, any idea how to
really disable the popup blocker ?

Thanks.
Betsy.
 
I'm trying to do some pointer manipulation and can not avoid using void *
as
the type declaration. I get this error message : error C2036 : 'void *' :
unknown size though. Is there a compiler option or a way to tell the
compiler
the size of void * to avoid this?

Your problem is that pointer arithmetic is dependent on the size of what the
pointer is pointing to:

int myArray[12];
int * test = &myArray[0];
test++;

the ++ operation moves the pointer not 1 byte, but sizeof(*test) bytes so
thaty it points to myArray[1];
void * does not have a type, so the compiler does not know what it should do
when + and - are applied. It does not point to anything that can be used for
size.

the solution is to cast to so what you mean it to be.
If you really want to do pointer aritmetic on a byte by byte basis, you have
to cast your pointer to char *.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
Back
Top