Skip to content

fix(c): macOS build — bump _POSIX_C_SOURCE so <stdio.h> declares snprintf - #14

Merged
phenomenon0 merged 1 commit into
mainfrom
fix/c-attic-macos-snprintf
Jun 21, 2026
Merged

fix(c): macOS build — bump _POSIX_C_SOURCE so <stdio.h> declares snprintf#14
phenomenon0 merged 1 commit into
mainfrom
fix/c-attic-macos-snprintf

Conversation

@phenomenon0

Copy link
Copy Markdown
Contributor

Problem

C (macos-latest) fails to build (C (ubuntu-latest) passes):

attic/c/glyph-codec/src/stream_validator.c:691: error: call to undeclared library function 'snprintf'

The file already #include <stdio.h>, but it first does #define _POSIX_C_SOURCE 199309L (for clock_gettime(CLOCK_MONOTONIC)). On Darwin that lowers __DARWIN_C_LEVEL below 199506L, which hides snprintf in <stdio.h>; Apple clang then errors on the implicit declaration. Linux glibc doesn't hide it, so only the macOS job failed. (Surfaced when the GitHub macOS runner image updated to a stricter Apple clang.)

Fix

Bump to _POSIX_C_SOURCE 200809L (POSIX.1-2008): still provides clock_gettime, and is ≥ 199506L so snprintf is declared on both Linux and macOS. One-line change in the parked C port; no behavior change.

Verification

Linux: make + make test green (lib builds, 14/14 C tests pass). macOS fix is the standard Darwin __DARWIN_C_LEVEL remedy.

🤖 Generated with Claude Code

attic/c/glyph-codec/src/stream_validator.c set _POSIX_C_SOURCE to 199309L for
clock_gettime/CLOCK_MONOTONIC. On Darwin that lowers __DARWIN_C_LEVEL below
199506L, which hides <stdio.h>'s snprintf declaration; Apple clang then treats
the call at line ~691 as an implicit-declaration error and the macOS C job fails
to build. Linux glibc does not hide it, so only `C (macos-latest)` failed
(`C (ubuntu-latest)` and the prior commit passed before the runner image bumped).

200809L (POSIX.1-2008) still provides clock_gettime and keeps __DARWIN_C_LEVEL
>= 199506L, so snprintf is declared on both platforms. Parked port; lib + 14
C tests build/pass on Linux.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@phenomenon0
phenomenon0 merged commit 76e8fe3 into main Jun 21, 2026
18 checks passed
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