Skip to content

Instantly share code, notes, and snippets.

View mikdusan's full-sized avatar

Michael Dusan mikdusan

View GitHub Profile
@mikdusan
mikdusan / empty - see comments
Created April 12, 2020 02:49
zig cc vs c++
empty - see comments
@mikdusan
mikdusan / stdcpp.diff
Created April 12, 2020 04:48
andrew's c++ / stdc++ patch
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 5214d49a3..23ab2a130 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -9252,6 +9252,9 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa
}
args.append("-nostdinc");
+ if (source_kind == FileExtCpp) {
+ args.append("-nostdinc++");
@mikdusan
mikdusan / unwrap.zig
Last active April 13, 2020 02:06
IR fun
export fn entry() void {
comptime {
var aaa: ?u64 = 333;
var answer: u64 = undefined;
answer = aaa.?;
}
}
pub fn panic(msg: []const u8, error_return_trace: ?*@import("builtin").StackTrace) noreturn {
while (true) {}
@mikdusan
mikdusan / master.diff
Created April 15, 2020 02:15
some progress on #1332
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 27bc6a04f..f9e336295 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -329,6 +329,9 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(EXE_CFLAGS "${EXE_CFLAGS} /w")
else()
set(EXE_CFLAGS "${EXE_CFLAGS} -Werror -Wall -Werror=implicit-fallthrough")
+ set(EXE_CFLAGS "${EXE_CFLAGS} -fcolor-diagnostics")
+ set(EXE_CFLAGS "${EXE_CFLAGS} -Wno-error=unused-variable")
@mikdusan
mikdusan / empty
Created April 17, 2020 09:30
looking at 5056 possibilities
empty
var storage_aaa: u32 = 1;
var storage_bbb: u32 = 2;
test "1" {
var aaa: ?*u32 = &storage_aaa;
var bbb: ?*u32 = &storage_bbb;
_ = aaa == bbb;
}
test "2" {
var aaa: ?*u32 = &storage_aaa;
const std = @import("std");
const mem = std.mem;
const io = std.io;
const Bar = struct {
const Self = @This();
arena: std.heap.ArenaAllocator,
raw_frame_reader: RawFrameReader,
const std = @import("std");
fn stringForUnsigned(comptime value: usize) []const u8 {
if (value == 0) return "0";
const base = 10;
const base_digits = "0123456789";
const ndigits = 1 + @floatToInt(
usize,
std.math.floor(std.math.log2(@intToFloat(f64, value)) / std.math.log2(@intToFloat(f64, base))),
const std = @import("std");
const os = std.os;
const testing = std.testing;
const warn = std.debug.warn;
test "empty" {
try depTokenizer("", "");
}
test "empty lf" {
try depTokenizer("\n", "");
diff --git a/src-self-hosted/Module.zig b/src-self-hosted/Module.zig
index 5bdd38c69..d8a6e4f3b 100644
--- a/src-self-hosted/Module.zig
+++ b/src-self-hosted/Module.zig
@@ -667,9 +667,10 @@ pub fn getAllErrorsAlloc(self: *Module) !AllErrors {
assert(errors.items.len == self.totalErrorCount());
+ const tmp = try arena.allocator.dupe(AllErrors.Message, errors.items);
return AllErrors{