type casting problem

V

Venn Syii

I do the following:

->Lock( 0, 0, (BYTE**)&pVertices, DUSAGE_WRITEONLY )

And get the following error:

error C2664: 'Lock' : cannot convert parameter 3 from 'unsigned char ** ' to
'void ** '

Any ideas?

Regards,
Venn
 
M

Matthias =?ISO-8859-1?Q?K=E4ppler?=

What is the type of pVertices?
What is the specification of Lock?
What is BYTE? Some MS specific typedef for unsigned char?
 
D

Dave O'Hearn

Venn said:
I do the following:

->Lock( 0, 0, (BYTE**)&pVertices, DUSAGE_WRITEONLY )

And get the following error:

error C2664: 'Lock' : cannot convert parameter 3 from
'unsigned char ** ' to 'void ** '

Any ideas?

Apparently BYTE is a typedef of unsigned char.

It looks like the Lock member function wants void **, not unsigned char
**. So don't use BYTE **; use void **. Check its documentation or
declaration to be sure though.
 
V

Victor Bazarov

Venn said:
I do the following:

->Lock( 0, 0, (BYTE**)&pVertices, DUSAGE_WRITEONLY )

And get the following error:

error C2664: 'Lock' : cannot convert parameter 3 from 'unsigned char ** ' to
'void ** '

Any ideas?

How is 'Lock' function declared? If it's a class, what the declaration
of its constructor? And why are you trying to cast '&pVertices' to
'BYTE**'? Your compiler is telling you that it expects a pointer to
a pointer to void as the third argument. What's the documentation say
about the use of the third argument?

V
 
D

Dave O'Hearn

Dave said:
Apparently BYTE is a typedef of unsigned char.

It looks like the Lock member function wants void **, not
unsigned char **. So don't use BYTE **; use void **. Check its
documentation or declaration to be sure though.

It must be early in the morning. I forgot to note that casts to void
pointers are often implicit. So you can simply try deleting your cast.
 
V

Victor Bazarov

Dave said:
It must be early in the morning. I forgot to note that casts to void
pointers are often implicit. So you can simply try deleting your cast.

There is a standard conversion from T* to void*, but he cannot delete
the cast (although he can certainly try), since there is no standard
conversion from T** to void**. Example:

void foo(void **p) {}

int main()
{
void *pv = 0;
foo(&pv); // OK
unsigned char *pc = 0;
foo(&pc); // error
}

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,978
Members
47,578
Latest member
LC_06

Latest Threads

Top