Hacker News new | past | comments | ask | show | jobs | submit login

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".



I 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 :^)


Well, 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.


My 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").


It's a hobby OS. That makes cuteness a lot more okay than other contexts.


well, 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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: