From ac85a2f3d621758c8302a0c6956d5ca30b833e73 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 25 Mar 2026 08:40:27 -0700 Subject: [PATCH] terminal: always use C ABI for now --- src/lib_vt.zig | 3 +++ src/terminal/lib.zig | 14 ++++++-------- src/terminal/main.zig | 3 ++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/lib_vt.zig b/src/lib_vt.zig index a7d7171bc..0a749be87 100644 --- a/src/lib_vt.zig +++ b/src/lib_vt.zig @@ -264,4 +264,7 @@ test { _ = terminal; _ = @import("lib/main.zig"); @import("std").testing.refAllDecls(input); + if (comptime terminal.options.c_abi) { + _ = terminal.c_api; + } } diff --git a/src/terminal/lib.zig b/src/terminal/lib.zig index 8e8acf89d..3cd657b4e 100644 --- a/src/terminal/lib.zig +++ b/src/terminal/lib.zig @@ -5,14 +5,12 @@ const lib = @import("../lib/main.zig"); /// The target for the terminal lib in particular. pub const target: lib.Target = if (build_options.c_abi) .c else .zig; -/// The calling convention to use for C APIs. If we're not building for -/// C ABI then we use auto which allows our C APIs to be cleanly called -/// by Zig. This is required because we modify our struct layouts based -/// on C ABI too. -pub const calling_conv: std.builtin.CallingConvention = if (build_options.c_abi) - .c -else - .auto; +/// The calling convention to use for C APIs. +/// +/// This is always .c for now. I want to make this "Zig" when we're not +/// building the C ABI but there are bigger issues we need to resolve to +/// make that possible (change it and see for yourself). +pub const calling_conv: std.builtin.CallingConvention = .c; /// Forwarded decls from lib that are used. pub const alloc = lib.allocator; diff --git a/src/terminal/main.zig b/src/terminal/main.zig index 3253a95ed..9f5b65e34 100644 --- a/src/terminal/main.zig +++ b/src/terminal/main.zig @@ -73,7 +73,8 @@ pub const Attribute = sgr.Attribute; pub const Options = @import("build_options.zig").Options; pub const options = @import("terminal_options"); -pub const c_api = @import("c/main.zig"); +/// This is set to true when we're building the C library. +pub const c_api = if (options.c_abi) @import("c/main.zig") else void; test { @import("std").testing.refAllDecls(@This());