authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-12-01 11:31:18+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-03 12:50:42-05:00
log621c08e692256af9b0cc5ef6438b0ecf547e2b38
treeec6b53315205aa48eb1c048971faa9cf0c083efe
parent20bcdab462dc21dc912da3ce4deb432a81cbc3c5
signature Commit is signed but in an unrecognized format.

exported main must be pub


4 files changed, 8 insertions(+), 8 deletions(-)

lib/std/special/start.zig+1-1
...@@ -23,7 +23,7 @@ comptime {...@@ -23,7 +23,7 @@ comptime {
23 .Unknown => unreachable,23 .Unknown => unreachable,
24 .Exe => {24 .Exe => {
25 if (builtin.link_libc) {25 if (builtin.link_libc) {
26 if (!@hasDecl(root, "main") or26 if (@hasDecl(root, "main") and
27 @typeInfo(@typeOf(root.main)).Fn.calling_convention != .C)27 @typeInfo(@typeOf(root.main)).Fn.calling_convention != .C)
28 {28 {
29 @export("main", main, .Weak);29 @export("main", main, .Weak);
test/compare_output.zig+4-4
...@@ -6,7 +6,7 @@ const tests = @import("tests.zig");...@@ -6,7 +6,7 @@ const tests = @import("tests.zig");
6pub fn addCases(cases: *tests.CompareOutputContext) void {6pub fn addCases(cases: *tests.CompareOutputContext) void {
7 cases.addC("hello world with libc",7 cases.addC("hello world with libc",
8 \\const c = @cImport(@cInclude("stdio.h"));8 \\const c = @cImport(@cInclude("stdio.h"));
9 \\export fn main(argc: c_int, argv: [*][*]u8) c_int {9 \\pub export fn main(argc: c_int, argv: [*][*]u8) c_int {
10 \\ _ = c.puts("Hello, world!");10 \\ _ = c.puts("Hello, world!");
11 \\ return 0;11 \\ return 0;
12 \\}12 \\}
...@@ -139,7 +139,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -139,7 +139,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
139 \\ @cInclude("stdio.h");139 \\ @cInclude("stdio.h");
140 \\});140 \\});
141 \\141 \\
142 \\export fn main(argc: c_int, argv: [*][*]u8) c_int {142 \\pub export fn main(argc: c_int, argv: [*][*]u8) c_int {
143 \\ if (is_windows) {143 \\ if (is_windows) {
144 \\ // we want actual \n, not \r\n144 \\ // we want actual \n, not \r\n
145 \\ _ = c._setmode(1, c._O_BINARY);145 \\ _ = c._setmode(1, c._O_BINARY);
...@@ -286,7 +286,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -286,7 +286,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
286 \\ }286 \\ }
287 \\}287 \\}
288 \\288 \\
289 \\export fn main() c_int {289 \\pub export fn main() c_int {
290 \\ var array = [_]u32{ 1, 7, 3, 2, 0, 9, 4, 8, 6, 5 };290 \\ var array = [_]u32{ 1, 7, 3, 2, 0, 9, 4, 8, 6, 5 };
291 \\291 \\
292 \\ c.qsort(@ptrCast(?*c_void, array[0..].ptr), @intCast(c_ulong, array.len), @sizeOf(i32), compare_fn);292 \\ c.qsort(@ptrCast(?*c_void, array[0..].ptr), @intCast(c_ulong, array.len), @sizeOf(i32), compare_fn);
...@@ -314,7 +314,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -314,7 +314,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
314 \\ @cInclude("stdio.h");314 \\ @cInclude("stdio.h");
315 \\});315 \\});
316 \\316 \\
317 \\export fn main(argc: c_int, argv: [*][*]u8) c_int {317 \\pub export fn main(argc: c_int, argv: [*][*]u8) c_int {
318 \\ if (is_windows) {318 \\ if (is_windows) {
319 \\ // we want actual \n, not \r\n319 \\ // we want actual \n, not \r\n
320 \\ _ = c._setmode(1, c._O_BINARY);320 \\ _ = c._setmode(1, c._O_BINARY);
test/stage2/compare_output.zig+2-2
...@@ -5,7 +5,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -5,7 +5,7 @@ pub fn addCases(ctx: *TestContext) !void {
5 // hello world5 // hello world
6 try ctx.testCompareOutputLibC(6 try ctx.testCompareOutputLibC(
7 \\extern fn puts([*]const u8) void;7 \\extern fn puts([*]const u8) void;
8 \\export fn main() c_int {8 \\pub export fn main() c_int {
9 \\ puts("Hello, world!");9 \\ puts("Hello, world!");
10 \\ return 0;10 \\ return 0;
11 \\}11 \\}
...@@ -14,7 +14,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -14,7 +14,7 @@ pub fn addCases(ctx: *TestContext) !void {
14 // function calling another function14 // function calling another function
15 try ctx.testCompareOutputLibC(15 try ctx.testCompareOutputLibC(
16 \\extern fn puts(s: [*]const u8) void;16 \\extern fn puts(s: [*]const u8) void;
17 \\export fn main() c_int {17 \\pub export fn main() c_int {
18 \\ return foo("OK");18 \\ return foo("OK");
19 \\}19 \\}
20 \\fn foo(s: [*]const u8) c_int {20 \\fn foo(s: [*]const u8) c_int {
test/standalone/hello_world/hello_libc.zig+1-1
...@@ -7,7 +7,7 @@ const c = @cImport({...@@ -7,7 +7,7 @@ const c = @cImport({
77
8const msg = "Hello, world!\n";8const msg = "Hello, world!\n";
99
10export fn main(argc: c_int, argv: **u8) c_int {10pub export fn main(argc: c_int, argv: **u8) c_int {
11 if (c.printf(msg) != @intCast(c_int, c.strlen(msg))) return -1;11 if (c.printf(msg) != @intCast(c_int, c.strlen(msg))) return -1;
12 return 0;12 return 0;
13}13}