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

scrolling through http://git.suckless.org/st/plain/st.c I stumbled upon

    #define LEN(a) (sizeof(a) / sizeof(a)[0])
I know precompiler magic is hard, and my C aint the best

but it makes me wonder if the parens at the end make sense - shouldn't it be something like

    #define LEN(a) (sizeof(a) / sizeof((a)[0]))
also asked here https://stackoverflow.com/questions/42001665/is-this-a-plain...



i'm not saying that the way they wrote it makes sense, but you have to remember that sizeof is actually an operator and not a function.


just got basically the same answer on stackoverflow - sizeof is an operator -> works w/o parens - makes sense - that's why i'm asking




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

Search: