type casting problem



 DEVELOP > c-Plus-Plus > type casting problem

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Venn Syii"
Date: 10 Dec 2004 07:41:51 AM
Object: type casting problem
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
.

User: "Dave OHearn"

Title: Re: type casting problem 10 Dec 2004 08:22:59 AM
Venn Syii wrote:

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.
--
Dave O'Hearn
.
User: "Dave OHearn"

Title: Re: type casting problem 10 Dec 2004 08:50:59 AM
Dave O'Hearn wrote:

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.
--
Dave O'Hearn
.
User: "Victor Bazarov"

Title: Re: type casting problem 10 Dec 2004 09:05:46 AM
Dave O'Hearn wrote:

Dave O'Hearn wrote:

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.

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
.



User: "Victor Bazarov"

Title: Re: type casting problem 10 Dec 2004 08:30:08 AM
Venn Syii wrote:

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
.

User: "Matthias =?ISO-8859-1?Q?K=E4ppler?="

Title: Re: type casting problem 10 Dec 2004 08:06:50 AM
What is the type of pVertices?
What is the specification of Lock?
What is BYTE? Some MS specific typedef for unsigned char?
Venn Syii wrote:

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

.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER