Dev Radar
Support
LiveUpdated 2026-10-30 21:12 UTC

The classic C macro # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) has a nasty…

The classic C macro # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) has a nasty problem. pass it a pointer instead…

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

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.