variable initializations are now mandatory
use `undefined` if you want uninitialized memory
This commit is contained in:
@@ -18,11 +18,10 @@ pub fn main(args: [][]u8) -> %void {
|
||||
} else if (arg[0] == '-') {
|
||||
return usage(exe);
|
||||
} else {
|
||||
var is: InputStream;
|
||||
is.open(arg, OpenReadOnly) %% |err| {
|
||||
var is = input_stream_open(arg, OpenReadOnly) %% |err| {
|
||||
%%stderr.print("Unable to open file: {}", ([]u8)(err));
|
||||
return err;
|
||||
}
|
||||
};
|
||||
defer is.close();
|
||||
|
||||
catted_anything = true;
|
||||
@@ -40,7 +39,7 @@ fn usage(exe: []u8) -> %void {
|
||||
}
|
||||
|
||||
fn cat_stream(is: InputStream) -> %void {
|
||||
var buf: [1024 * 4]u8;
|
||||
var buf: [1024 * 4]u8 = undefined;
|
||||
|
||||
while (true) {
|
||||
const bytes_read = is.read(buf) %% |err| {
|
||||
|
||||
@@ -6,7 +6,7 @@ import "rand.zig";
|
||||
pub fn main(args: [][]u8) -> %void {
|
||||
%%stderr.print_str("Welcome to the Guess Number Game in Zig.\n");
|
||||
|
||||
var seed : u32;
|
||||
var seed : u32 = undefined;
|
||||
const seed_bytes = (&u8)(&seed)[0...4];
|
||||
%%os_get_random_bytes(seed_bytes);
|
||||
|
||||
@@ -16,7 +16,7 @@ pub fn main(args: [][]u8) -> %void {
|
||||
|
||||
while (true) {
|
||||
%%stderr.print_str("\nGuess a number between 1 and 100: ");
|
||||
var line_buf : [20]u8;
|
||||
var line_buf : [20]u8 = undefined;
|
||||
|
||||
const line_len = stdin.read(line_buf) %% |err| {
|
||||
%%stderr.print_str("Unable to read from stdin.\n");
|
||||
|
||||
Reference in New Issue
Block a user