4 ms·
I use the convention "size = number of bytes" (as in sizeof), "count = number of elements" and so my sizeof(x)/sizeof(x[0]) macro is actually called COUNT.
by userbinator 12y ago
I use the convention "size = number of bytes" (as in sizeof), "count = number of elements" and so my sizeof(x)/sizeof(x[0]) macro is actually called COUNT.
- clarry 12y agoIn the BSDs (and some other code bases) the macro is spelled nitems and is common enough to be considered idiomatic.
- kayamon 12y agoI always call mine "countof" to match the "sizeof" naming convention.
- noselasd 12y agohttps://msdn.microsoft.com/en-us/library/ms175773.aspx https://msdn.microsoft.com/en-us/library/ms175773.aspx - although I'm not sure it's a macro. The nice thing is it's detecting that you actually give it an array.