The classic C macro # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) has a nasty…
This is a dev post classified by AGK Intelligence as Languages & runtimes (a tutorial), kept by the Dev Radar because it carries real work, not commentary.
The classic C macro # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) has a nasty problem. pass it a pointer instead of an actual array, and it can silently return the wrong element count. older Linux kernels had a clever solution. They used a compiler type check inside a negative-width bit-field: int:(-!!(e)). Pass a real array, and the check adds zero. Pass a pointer, and the bit-field width becomes negative, causing compilation to fail. Here's the macro chain used in older Linux kernels:
Posted by Arika (9k followers) 2 days ago · 170 likes · 9.5k views · view the original post on X. Kept by the Dev Radar as Languages & runtimes.
More dev work like this
- Whenever someone interacts with a website, that's potential data a marketer can analyze. — @freeCodeCamp
- Roundhouse turns Rails apps into standalone binaries or services in Rust, Swift,… — @rustaceans_rs
- We're starting work on Pydantic V3. — @pydantic
- zuvloop: a drop-in asyncio event loop, powered by libuv and written in Zig ⚡ — @marcelotryle
- Small Crates Behind Big Rust Systems — @rustaceans_rs
- js tip. infinity — @xah_lee
- massive tech geeking on javascript. — @xah_lee
- Infinity is a lightweight Rust framework for massively concurrent agents—75k fit on a… — @rustaceans_rs
Every post is read and classified by AGK Intelligence: what it is, which market it belongs to, and whether the link is a real tool. 31.2k posts from 5k X accounts over the last 21 days, 8.8k tools, 12 markets. New posts are collected several times an hour and the full ranking is recomputed every hour — last update 2026-10-30 21:12 UTC. Full method.