3 ms·
See WalterBright's 2009 blog post, C’s Biggest Mistake, about exactly this. https://digitalmars.com/articles/C-biggest-mistake.html https://digitalmars.com/art
by MaxBarraclough 6y ago
See WalterBright's 2009 blog post, C’s Biggest Mistake, about exactly this.
https://digitalmars.com/articles/C-biggest-mistake.html https://digitalmars.com/articles/C-biggest-mistake.html
- kiwidrew 6y agoAh, indeed! Thanks for the link. I think many of the "safe C" variants get tripped up by starting with fat pointers (length + pointer as an atomic value) and then have trouble (rightly so!) when trying to squeeze them through the C standard ABI; it's a square peg in round hole sort of situation. The key observation from WalterBright's post is that the C standard ABI already has a way to pass fat pointers, using a pair of arguments (size_t and char *) in an ad-hoc manner. It's the not-useful-but-legal C99 VLA declaration in the function prototype that could, if one is willing to violate the C99 spec, allow a compiler to automatically derive a fat pointer inside the body of a function in a manner that is backwards-compatible with the C standard ABI.