-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Problem
Large parts of the codebase are written in a C89/C90 style (e.g., loop-scope variables declared at function scope, manual index manipulation, macro-heavy helpers). This makes the code harder to read and reason about, and it limits the use of clearer C99/C11 constructs.
Proposed direction
Adopt C99 as the project baseline (and selectively use C11 where it improves clarity) to modernize code style and reduce macro reliance.
Examples (non-exhaustive)
- Loop-scope variables: prefer
for (size_t i = 0; i < n; i++)over function-scopesize_t i;+ loop reuse. This removes accidental reuse and keeps variable lifetimes tight. - Safer/clearer helpers: replace macro-heavy constructs (e.g.,
MIN/MAX, assertion macros with side effects) withstatic inlinefunctions. This improves type safety and debuggability. - stdbool/size_t: use
<stdbool.h>forbooland<stddef.h>/size_tfor sizes instead of ad‑hocint/unsigned longusage to reduce format/overflow mistakes. - Designated initializers: prefer
{ .field = value }for clarity in large structs. - Explicit casts and enums: tighten enum usage and avoid implicit int assumptions.
Benefits
- Better readability and maintainability (fewer hidden macro tricks).
- Safer, more explicit code with tighter variable scopes.
- Easier static analysis and fewer false positives from linters.
- Simplified onboarding and contribution (modern C expectations).
Acceptance criteria
- Documented C99/C11 baseline (CMake + Autotools) and scope of modernization.
- Initial pass converts a small, representative subset of files with clear before/after examples.
- No functional regressions (build + existing tests pass).
Notes
- Keep changes incremental (file-by-file) to avoid huge PRs.
- Be conservative with C11 features; only use them where they clearly improve readability or safety.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels