Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows-specific note about stdout initialization at compile-time #94

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KorryKatti
Copy link
Contributor

Added a note about Windows behavior when using const stdout = std.io.getStdOut().writer() outside functions. On Windows, this expression is evaluated at compile-time, which may cause issues. The solution is to place it inside a function to avoid compile-time evaluation.

@pedropark99
Copy link
Owner

Uhmm, interesting, do you know if this issue is documented somewhere? Maybe in a GitHub issue? Or, in a specific section of the official Zig docs?

@KorryKatti
Copy link
Contributor Author

Uhmm, interesting, do you know if this issue is documented somewhere? Maybe in a GitHub issue? Or, in a specific section of the official Zig docs?

my only knowledge of zig is from your book really 😅but i noticed this problem while coding and confirmed with 2-3 more people who i know.

@KorryKatti
Copy link
Contributor Author

when the stdout is outside the pub fn function:

error:

image

code:

image

when stdout is inside the function :

output :

image

code:

image

@KorryKatti
Copy link
Contributor Author

it is probably a windows only problem

@pedropark99
Copy link
Owner

Found two issues that document this specific requirement on Windows:

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.

2 participants