|
|
|
|
|
by locknitpicker
2 days ago
|
|
> You’re really citing a mess in a Ruby code base caused by lack of typing as evidence for why void * is problematic in C/C++? If you read GP's post you'll understand it exemplifies exactly the issue that the likes of (void *) present in C. I mean, read the message, particularly this: > later on it's not that easy to understand which shape it should have in the specific conditional branch you're trying to fix That is exactly the purpose of void *. By design. It's a pointer to an unspecified type. The unspecified type is exactly why this thing is used. |
|
This is not idiomatic C. I have no doubt that someone (likely many someones) have written a function that takes a void * and then internally does some insane half baked dynamic typing. But I’ve never seen it and it’s not common.
You also cannot fix this behavior by changing the pointer type. The type of the pointer is essentially meaningless in this case.
> That is exactly the purpose of void *. By design. It's a pointer to an unspecified type. The unspecified type is exactly why this thing is used.
This is also the purpose of byte * in the examples. Coercing an arbitrary pointer from void to byte doesn’t accomplish anything. It’s lipstick on a pig at best.