#how do i access buffered writer from anywhere

1 messages · Page 1 of 1 (latest)

vast narwhal
#

i want to be able to call stdout.print() and bw.flush() from anywhere, so that i can flush output together instead of separately.

taking```
const stdout_file = std.io.getStdOut().writer();
var bw = std.io.bufferedWriter(stdout_file);
const stdout = bw.writer();

how do i go about this?
rocky tartan
#

define then intialize at runtime

var hw: std.io.BufferedWriter(...) = undefined;

pub fn main() void {
  hw = std.io.bufferedWriter(std.io.getStdOut().writer());
}
vast narwhal
#

i can't get it to work... what type should my variable be?

vast narwhal
#

supposedly the type is
io.buffered_writer.BufferedWriter(4096,io.GenericWriter(fs.File,error{DiskQuota,FileTooBig,InputOutput,NoSpaceLeft,DeviceBusy,InvalidArgument,AccessDenied,BrokenPipe,SystemResources,OperationAborted,NotOpenForWriting,LockViolation,WouldBlock,ConnectionResetByPeer,Unexpected},(function 'write')))
but i can't get that to work either

#

even when i try fiddling around to change some things

vapid cobalt
#

std.io.BufferedWriter(4096, std.fs.File.Writer)