[ENet-discuss] Using packet-data w/o a memcpy()?

RAULO Emmanuel IT&L@bs emmanuel.raulo at orange-ftgroup.com
Wed May 12 01:30:04 PDT 2010


> My reading of the docs indicate that event.packet-data is a enet_uint8 *, 
> which is typecast from a pointer to char.  This implies that I should be able 
> to cast it to void*
>   
Yup, any pointer type can be cast to void*.

> void	*buffer;
>
> buffer = (void) event.packet->data;
>
> But this didn't seem to work.  Like I said, I'm a bit rusty...  So I was on 
> the right track?  I just have to fiddle with syntax, then.
>   
That should be buffer = (void*)event.packet->data; as you want a pointer.
You don't even have to cast explicitely as void* is a "more general" 
type than uint8* so buffer=event.packet->data; will work as well.
Explicit cast is only needed with pointers when the destination type is 
"more specific" than the original type, e.g. struct SomeStruct 
*structPtr = (struct SomeStruct*)buffer;

Regards,

--
Emmanuel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: emmanuel_raulo.vcf
Type: text/x-vcard
Size: 374 bytes
Desc: not available
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20100512/5ec23893/attachment.vcf>


More information about the ENet-discuss mailing list