Skip to content

Conversation

@Lukasa
Copy link
Contributor

@Lukasa Lukasa commented Jan 24, 2025

Motivation

It's tempting for us to use the FILE * for stderr whenever we want to print to it. However, the Linux libc modules aren't appropriately annotated to call that field constant, and indeed it isn't. This causes Swift to throw a fit if we even touch it.

Modifications

Introduce an awkward function that issues direct writes to stderr instead of using the FILE *.

Result

Swift is happier.

Motivation

It's tempting for us to use the FILE * for stderr whenever we
want to print to it. However, the Linux libc modules aren't
appropriately annotated to call that field constant, and indeed it
isn't. This causes Swift to throw a fit if we even touch it.

Modifications

Introduce an awkward function that issues direct writes to
stderr instead of using the FILE *.

Result

Swift is happier.
@Lukasa Lukasa added the 🔨 semver/patch No public API change. label Jan 24, 2025
@Lukasa Lukasa enabled auto-merge (squash) January 24, 2025 16:09
@Lukasa Lukasa merged commit 85742bc into apple:main Jan 24, 2025
33 of 35 checks passed
@Lukasa Lukasa deleted the cb-avoid-using-stderr branch January 24, 2025 16:42
var buf = buf
while buf.count > 0 {
// 2 is stderr
let rc = write(2, buf.baseAddress, buf.count)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use STDERR_FILENO instead of the hardcoded int

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants