You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement checked array.h API and align docs with the site.
Replace the prototype header with overflow-safe growth, try_* accessors, and strict-C portability, then document the contracts and add compile-proof tests so doc snippets stay verified.
Co-authored-by: Cursor <cursoragent@cursor.com>
Copy file name to clipboardExpand all lines: docs/overview.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,13 @@ Unchecked compatibility APIs:
78
78
- Assume preconditions are already true.
79
79
- Are concise, but undefined behavior is possible if used incorrectly (for example, out-of-bounds access or last-element access on empty arrays).
80
80
81
+
## Portability
82
+
83
+
-`array_size_t` is a `size_t` alias used for counts, capacities, and slice lengths.
84
+
- Strict C11/C17 (`-std=c11 -pedantic`): use `array_for_each_t(T, arr, it)` and typed slice macros. `ARRAY_HAS_TYPEOF` is `0`.
85
+
- GNU/Clang convenience (`-std=gnu11` or non-pedantic GCC/Clang): `ARRAY_HAS_TYPEOF` is `1`, enabling `array_for_each` and `slice_from_array`.
86
+
-`array_try_push` accepts scalar rvalues (for example `array_try_push(arr, 10)`) via C11 `_Generic`. For struct or other non-scalar element types, use `array_try_push_lvalue(arr, value)` with an lvalue.
0 commit comments