3 ms·
Don't get me started... It is called a struct. It holds arbitrary collection of any type of data safely while enabling the lazy programmer to pass only one par
by nocsaer1 11y ago
Don't get me started...
It is called a struct. It holds arbitrary collection of any type of data safely while enabling the lazy programmer to pass only one parameter around. It is also safe (as must as it can be in C) unlike pointers that hide data behind their back and are just asking for trouble.
I will ignore all the problems and point out the worst offender, stack allocation example. That is not how you allocate arbitrary data on the stack, automatic char array is not malloc. In fact, in C you can't do it without using special platform specific functions. Anything else will cause undefined behavior.
- ploxiln 11y agoVariable length arrays on the stack are in the C99 standard. (If you're using Microsoft stuff, you have my condolences.)
- nocsaer1 11y agoMy argument doesn't rely on their (non) availability.
- mistercow 11y agoI think the reason for this is that they're trying to manipulate C's syntax to get a certain kind of intuitive style. They seem to want it to be concise and C-like (without resorting to macros), but they want to add their own functionality without actually extending the language. In this case, they want you to just be able to cast a Cello "var" pointer to a specific type pointer using the normal cast syntax. I'm not saying it's the right choice. Just that I understand why they did it that way. Still, I think a macro would be a perfectly reasonable way to do it.