Skip to content

Commit 1bbee32

Browse files
committed
Replace main.c with main.zig
1 parent e24d314 commit 1bbee32

File tree

7 files changed

+10
-37
lines changed

7 files changed

+10
-37
lines changed

build.zig

+1-25
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,7 @@
11
const Builder = @import("std").build.Builder;
22

33
pub fn build(b: &Builder) {
4-
const exe = b.addCExecutable("main");
5-
b.addCIncludePath(".");
6-
exe.addCompileFlags([][]const u8 {
7-
"-std=c99",
8-
"-nostdlib",
9-
});
10-
11-
const source_files = [][]const u8 {
12-
"main.c",
13-
};
14-
15-
for (source_files) |source| {
16-
exe.addSourceFile(source);
17-
}
18-
19-
const zig_source_files = [][]const u8 {
20-
"compute.zig",
21-
"compute_helper.zig",
22-
"display.zig",
23-
};
24-
25-
for (zig_source_files) |source| {
26-
const object = b.addObject(source, source);
27-
exe.addObject(object);
28-
}
4+
const exe = b.addExecutable("main", "main.zig");
295

306
exe.setOutputPath("./main");
317
b.default_step.dependOn(&exe.step);

compute.h

-1
This file was deleted.

compute.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pub use @import("compute_helper.zig");
1+
use @import("compute_helper.zig");
22

3-
export fn compute(a: u8) -> u8 {
3+
pub fn compute(a: u8) -> u8 {
44
compute_helper(a) + 5
55
}

display.h

-1
This file was deleted.

display.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const std = @import("std");
22
const printf = std.io.stdout.printf;
33

4-
export fn display_char(c: u8)
4+
pub fn display_char(c: u8)
55
{
66
%%printf("{c}\n", c);
77
}

main.c

-7
This file was deleted.

main.zig

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use @import("display.zig");
2+
use @import("compute.zig");
3+
4+
pub fn main() -> %void {
5+
display_char(compute('A'));
6+
}

0 commit comments

Comments
 (0)