liveBook · Manning

Minimum-bound array parameter

As explained in Modern C

A minimum-bound array parameter is a C array-parameter declaration whose static bound promises that the argument points to at least the specified number of elements.

void func(double a[static 7]); Here, static 7 promises that a is a pointer to at least seven double elements. The declaration describes an interface requirement, not an array stored inside the parameter. section 15.0

TAKEAWAY: Use static N when a function expects a non-null pointer to a collection containing at least N elements. A static 1 parameter expresses the corresponding promise for a single object. section 15.0

Choose the parameter form that matches the permitted argument:

  • double a[static 1] — pointer to one object; the argument must be non-null. section 15.0
  • double a[static 7] — pointer to a collection with at least seven elements. section 15.0
  • double a[n] — pointer to a collection whose required count is supplied by n. section 15.0
  • double *a — permits a single object or a null pointer, provided execution remains defined for null. section 15.0
void func(double a[static 7]);
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":4}],[{\"line\":0,\"ch\":10},{\"line\":0,\"ch\":16}],[{\"line\":0,\"ch\":19},{\"line\":0,\"ch\":27}]]"}
!@%STYLE%@!

Compare the complete static-bound declaration directly with the promised minimum of seven elements. section 15.0

How Modern C covers it

How deep it goes
Defines static 1 and static N contracts, contrasts VLA and pointer syntax, and notes limited compiler diagnostics.
Examples
Uses void func(double a[static 1]), void func(double a[static 7]), and void func(size_t n, double a[n]).
What it assumes
Assumes familiarity with C functions, pointers, and array-parameter syntax while distinguishing their interface roles.
What you can do after
Apply it via C function declarations to state non-null and minimum-element requirements clearly.
How it connects
Connects array parameters with pointers, variable-length arrays, null pointers, and out-of-bounds errors.

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.