Commit 621c08e692

Vexu <git@vexu.eu>
2019-12-01 10:31:18
exported main must be pub
1 parent 20bcdab
Changed files (4)
lib
std
special
test
lib/std/special/start.zig
@@ -23,7 +23,7 @@ comptime {
         .Unknown => unreachable,
         .Exe => {
             if (builtin.link_libc) {
-                if (!@hasDecl(root, "main") or
+                if (@hasDecl(root, "main") and
                     @typeInfo(@typeOf(root.main)).Fn.calling_convention != .C)
                 {
                     @export("main", main, .Weak);
test/stage2/compare_output.zig
@@ -5,7 +5,7 @@ pub fn addCases(ctx: *TestContext) !void {
     // hello world
     try ctx.testCompareOutputLibC(
         \\extern fn puts([*]const u8) void;
-        \\export fn main() c_int {
+        \\pub export fn main() c_int {
         \\    puts("Hello, world!");
         \\    return 0;
         \\}
@@ -14,7 +14,7 @@ pub fn addCases(ctx: *TestContext) !void {
     // function calling another function
     try ctx.testCompareOutputLibC(
         \\extern fn puts(s: [*]const u8) void;
-        \\export fn main() c_int {
+        \\pub export fn main() c_int {
         \\    return foo("OK");
         \\}
         \\fn foo(s: [*]const u8) c_int {
test/standalone/hello_world/hello_libc.zig
@@ -7,7 +7,7 @@ const c = @cImport({
 
 const msg = "Hello, world!\n";
 
-export fn main(argc: c_int, argv: **u8) c_int {
+pub export fn main(argc: c_int, argv: **u8) c_int {
     if (c.printf(msg) != @intCast(c_int, c.strlen(msg))) return -1;
     return 0;
 }
test/compare_output.zig
@@ -6,7 +6,7 @@ const tests = @import("tests.zig");
 pub fn addCases(cases: *tests.CompareOutputContext) void {
     cases.addC("hello world with libc",
         \\const c = @cImport(@cInclude("stdio.h"));
-        \\export fn main(argc: c_int, argv: [*][*]u8) c_int {
+        \\pub export fn main(argc: c_int, argv: [*][*]u8) c_int {
         \\    _ = c.puts("Hello, world!");
         \\    return 0;
         \\}
@@ -139,7 +139,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
         \\    @cInclude("stdio.h");
         \\});
         \\
-        \\export fn main(argc: c_int, argv: [*][*]u8) c_int {
+        \\pub export fn main(argc: c_int, argv: [*][*]u8) c_int {
         \\    if (is_windows) {
         \\        // we want actual \n, not \r\n
         \\        _ = c._setmode(1, c._O_BINARY);
@@ -286,7 +286,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
         \\    }
         \\}
         \\
-        \\export fn main() c_int {
+        \\pub export fn main() c_int {
         \\    var array = [_]u32{ 1, 7, 3, 2, 0, 9, 4, 8, 6, 5 };
         \\
         \\    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 {
         \\    @cInclude("stdio.h");
         \\});
         \\
-        \\export fn main(argc: c_int, argv: [*][*]u8) c_int {
+        \\pub export fn main(argc: c_int, argv: [*][*]u8) c_int {
         \\    if (is_windows) {
         \\        // we want actual \n, not \r\n
         \\        _ = c._setmode(1, c._O_BINARY);