Skip to content

fix: posix.flow function names that are libc macros - #551

Merged
godofecht merged 1 commit into
mainfrom
fix/posix-libc-name-collisions
Aug 18, 2026
Merged

godofecht merged 1 commit into
mainfrom
fix/posix-libc-name-collisions

Conversation

@godofecht

@godofecht godofecht commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Small, unambiguous piece split out of #550.

lib/stdlib/posix.flow defines functions named stdin, stdout and stderr. Those are libc macros. On macOS stdin expands to __stdinp, so the generated C declares:

FileDescriptor __stdinp(void);

against libc's FILE *__stdinp, and every program importing the module fails:

error: redefinition of '__stdinp' as different kind of symbol

Renamed to stdin_fd / stdout_fd / stderr_fd, with a comment recording why so they do not get renamed back. There are no callers anywhere in lib/, examples/, tests/ or docs/, and the module has never been parseable, so nothing can depend on the old spelling.

This does not make the module usable on its own. The remaining blockers are prototype conflicts (conflicting types for 'read', because Flow's i32 signature meets libc's ssize_t and <unistd.h> is always included) and constants that shadow macros (O_RDONLY, SEEK_SET). Those need a decision about how Flow binds to POSIX, written up in #550 with three options and the tradeoffs. I did not want to guess at a stdlib API in passing.

Splitting this out because it is the one part with no design content.

Validation

  • Unit suite passes
  • --check-ledger reports no new unverified examples

stdin, stdout and stderr are macros. On macOS `stdin` expands to `__stdinp`,
so the generated C declared `FileDescriptor __stdinp(void)` against libc's
`FILE *__stdinp` and every program importing the module failed to compile:

    error: redefinition of '__stdinp' as different kind of symbol

Renamed to stdin_fd / stdout_fd / stderr_fd, with a comment saying why so
nobody renames them back. No callers anywhere in lib/, examples/, tests/ or
docs/, and the module has never been parseable, so nothing can depend on the
old spelling.

This does not make the module usable on its own. The prototype and constant
collisions behind that need a decision about how Flow binds to POSIX, which
is written up in #550.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@godofecht
godofecht merged commit 1811f64 into main Aug 18, 2026
19 checks passed
@godofecht
godofecht deleted the fix/posix-libc-name-collisions branch August 18, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant