Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The Linux kernel `container_of` and `offset_of` macros can be pretty handy when writing generic containers.


While those are both implemented as macros, I'd hardly call them "macro magic" at least not in the manner used by OP, or what I was talking about.

Both of those are actually rather simple macros doing what seems like a mess with pointers. The difference is subtle, but most strongly expressed in that the complexity is innate to the problem, and does not require mucking much with what is entirely weird macro behavior.




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

Search: