3 ms·
I fail to see how their overly clever solution is in any shape or form better than the regular approach shown under "How others declare them" – except for being
by adwn 4y ago
I fail to see how their overly clever solution is in any shape or form better than the regular approach shown under "How others declare them" – except for being a "cute" "hack".
- asddubs 4y agowell, obviously the advantage is that you don't have to enumerate all the architectures you support manually. Is it worth it? Ehhh, probably not, but the author isn't exactly advocating for it either
- akling 4y agoI find it neat that the code doesn't have to enumerate all the possible platforms it might be compiled on, and instead just takes something the compiler already provides and tweaks it. But yes, the "cute" "hack" aspect is the primary endearing factor :^)
- deleted 4y ago[deleted]
- self_awareness 4y agoMy thoughts exactly. What if __SIZE_TYPE__ stops being a macro someday? Also double-underscore prefixed symbols are compiler reserved, so any other compiler can use the same symbol for entirely different purpose, so compiler guards are needed when using it. I understand doing hacks when there's no other way around something, or when a hack is much cheaper than the proper solution, but in this case, I think those guys have chosen a more complicated, more expensive, less functional hack than a cheap and more complete proper solution (in "how others are doing it").
- calgarymicro 4y agoWell, he sorta says it at the end: >Other C libraries typically use more careful techniques, such as wrapping the declarations in architecture-specific #ifdefs They don't have to define it multiple times for different architectures. This is theoretically platform agnostic and saves a few lines. Not really that significant, but then again it's not like he's recommending people do it.
- jeffparsons 4y agoIt's a hobby OS. That makes cuteness a lot more okay than other contexts.