-
Notifications
You must be signed in to change notification settings - Fork 6
Output stream redirection
Chung Leong edited this page Mar 5, 2025
·
1 revision
When Zig code is compiled for native execution, the following functions of the C library are intercepted at the OS level:
fputcfprintffputsfwriteperrorprintfputcputcharputsvfprintfvprintfwrite
When the write target is stdout or stderr, output is redirect to the JavaScript console. You can
use __zigar.connect() to redirect it to a function of your choice.
Redirection only applies to the module in question. Calls made by shared libraries are unaffected.
When compiled for WebAssembly, output is sent to JavaScript through WASI.