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

fix(docs): update hello-world.zig for Windows compatibility #440

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

Conversation

jobansd
Copy link

@jobansd jobansd commented Feb 21, 2025

Description

Fixes: issue #438

Reference

  • Hello World sample doesn't work in Windows (Issue #438)
  • Declaring a const variable outside the main function fails on target x86_64-windows-gnu (Issue #6845)

TL;DR

getStdOut() only works at runtime on Windows. This is resolved by moving the getStdOut() call into the main function's scope. Additionally, ziggzagg.zig example on the same page uses the correct approach.

Fixes: [issue ziglang#438](ziglang#438)

- Hello World sample doesn't work in Windows [(Issue ziglang#438)](ziglang#438)
- Declaring a const variable outside the main function fails on target x86_64-windows-gnu [(Issue #6845)](ziglang/zig#6845 (comment))

`getStdOut()` only works at runtime on Windows. This is resolved by moving the `getStdOut()` call into the main function's scope. Additionally, [`ziggzagg.zig`](https://ziglang.org/learn/samples/#zigg-zagg) example on the same page uses the correct approach.
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.

Hello World sample doesn't work in Windows
1 participant