Re:Checked C
by Jasper_ on Wednesday December 21, 2022 @04:00PM
(#34086325)
Unfortunately, `int a[static 3][static 4]` does not work.
[ Parent
| on HN ]
That’s because you’d write it as:
int a[static 3][4]
You only need to put static on the outermost type, the one that decays into a pointer. Same thing applies if you need restrict: int a[static restrict 3][4]
which is ugly but gets the job done. Think of int a[3][4], when used as a function parameter, as “pointer to int[4]” (the 3 disappears completely), and think of int a[static 3][4] as “pointer to first of at least 3 int[4]”.(Not trying to defend C here, just explaining how C works.)