Skip to content

Comment on A nice, little known C feature: Static array indices in parameter declarationsparent

Comments

As another poster said, the compiler can't know inside the function body the size of the array passed if you just use sizeof.

More to a style/safety point, if I ever see a function that expects an array and doesn't also take the size of that array as another parameter, that's a bug waiting to happen.

Especially in this case since this feature seems to only throw a warning on recent versions of clang, and more or less nothing else.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.