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

1. Finding the size of a struct member (lifted from the Linux kernel)

#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))

2. Not strictly C: using `pahole` to analyze how structs are laid out in memory

https://linux.die.net/man/1/pahole



Last week I would have said “ok, but I’ll never need to do that”. This week I had to do exactly that (find the size of a struct member).




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: