authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-04-11 16:43:38-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-04-11 16:43:38-04:00
logc236cbff39de996cf862dfedbc92584ac09414d8
tree6932a6729486d4722646853dea75edb7521312f0
parenta6e288d5fe51d5373fa995b5eec2dd2325c1ea9f
parenteefe6956fde0adc2b0b56fdb6d22e06e2543219e
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #5003 from emekoi/fix-mingw

fix compilation under mingw

3 files changed, 24 insertions(+), 5 deletions(-)

CMakeLists.txt+3
......@@ -454,6 +454,9 @@ if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
454454 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
455455 )
456456 set(ZIG_EXECUTABLE "${zig_BINARY_DIR}/zig")
457 if (WIN32)
458 set(ZIG_EXECUTABLE "${ZIG_EXECUTABLE}.exe")
459 endif()
457460else()
458461 add_custom_target(zig_build_libstage2 ALL
459462 COMMAND "${ZIG_EXECUTABLE}" ${BUILD_LIBSTAGE2_ARGS}
doc/langref.html.in+1-1
......@@ -8167,7 +8167,7 @@ test "vector @splat" {
81678167 {#header_open|@tagName#}
81688168 <pre>{#syntax#}@tagName(value: var) []const u8{#endsyntax#}</pre>
81698169 <p>
8170 Converts an enum value or union value to a slice of bytes representing the name.
8170 Converts an enum value or union value to a slice of bytes representing the name.</p><p>If the enum is non-exhaustive and the tag value does not map to a name, it invokes safety-checked {#link|Undefined Behavior#}.
81718171 </p>
81728172 {#header_close#}
81738173
src-self-hosted/stage2.zig+20-4
......@@ -897,6 +897,22 @@ export fn stage2_libc_render(stage1_libc: *Stage2LibCInstallation, output_file:
897897 return .None;
898898}
899899
900fn enumToString(value: var, type_name: []const u8) ![]const u8 {
901 switch (@typeInfo(@TypeOf(value))) {
902 .Enum => |e| {
903 if (e.is_exhaustive) {
904 return std.fmt.allocPrint(std.heap.c_allocator, ".{}", .{@tagName(value)});
905 } else {
906 return std.fmt.allocPrint(std.heap.c_allocator,
907 "@intToEnum({}, {})",
908 .{type_name, @enumToInt(value)}
909 );
910 }
911 },
912 else => unreachable
913 }
914}
915
900916// ABI warning
901917const Stage2Target = extern struct {
902918 arch: c_int,
......@@ -1114,13 +1130,13 @@ const Stage2Target = extern struct {
11141130
11151131 .windows => try os_builtin_str_buffer.outStream().print(
11161132 \\ .windows = .{{
1117 \\ .min = .{},
1118 \\ .max = .{},
1133 \\ .min = {},
1134 \\ .max = {},
11191135 \\ }}}},
11201136 \\
11211137 , .{
1122 @tagName(target.os.version_range.windows.min),
1123 @tagName(target.os.version_range.windows.max),
1138 try enumToString(target.os.version_range.windows.min, "Target.Os.WindowsVersion"),
1139 try enumToString(target.os.version_range.windows.max, "Target.Os.WindowsVersion")
11241140 }),
11251141 }
11261142 try os_builtin_str_buffer.appendSlice("};\n");