CBE: add support for bool,u32

This commit is contained in:
Noam Preil 2020-11-18 20:50:51 -05:00 committed by Alex Cameron
parent 15a148db01
commit 37438dd789
2 changed files with 14 additions and 1 deletions

View File

@ -26,15 +26,19 @@ fn renderType(ctx: *Context, header: *C.Header, writer: std.ArrayList(u8).Writer
try writer.writeAll("zig_noreturn void");
},
.Void => try writer.writeAll("void"),
.Bool => try writer.writeAll("bool"),
.Int => {
if (T.tag() == .u8) {
header.need_stdint = true;
try writer.writeAll("uint8_t");
} else if (T.tag() == .u32) {
header.need_stdint = true;
try writer.writeAll("uint32_t");
} else if (T.tag() == .usize) {
header.need_stddef = true;
try writer.writeAll("size_t");
} else {
return ctx.fail(ctx.decl.src(), "TODO implement int types", .{});
return ctx.fail(ctx.decl.src(), "TODO implement int type {}", .{T});
}
},
else => |e| return ctx.fail(ctx.decl.src(), "TODO implement type {}", .{e}),

View File

@ -1,3 +1,12 @@
#if __STDC_VERSION__ >= 199901L
// C99 or newer
#include <stdbool.h>
#else
#define bool unsigned char
#define true 1
#define false 0
#endif
#if __STDC_VERSION__ >= 201112L
#define zig_noreturn _Noreturn
#elif __GNUC__