3 ms·
It's all fun and games until you say ++p and pass that to a function that is silently expecting a length and other stuff in front of it. Calling these thi
by kabdib 11y ago
It's all fun and games until you say
++p
and pass that to a function that is silently expecting a length and other stuff in front of it. Calling these things "pointers" is a bit of a promotion from what they really are. Naming them "char*" or whatever is pretty dangerous if you ever do pointer movement.
Seriously, if you want descriptors and typed blobs, just make up a struct for what you want and pass it around. Say what you mean. Lying like this is going to hurt you.
- mpu 11y agoThat's what Cello is about I think.
- tptacek 11y agoThis is also a common, and sometimes exploitable, coding error with C++ smart pointers. I agree with you: I'm not sure how this is any more powerful than any encapsulated ADT-style foo_t-wraps-a-void-star C library.
- Buge 11y agoWell with C++ unique_ptr and shared_ptr you cant ++ or += or even get a raw pointer without explicitly calling .get().