From 40a1ba0431a7d3755d2d428ff8b3c927c4f4b208 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 8 Sep 2023 14:53:18 -0700 Subject: [PATCH] math: use extern struct for guaranteed memory layout Signed-off-by: Stephen Gutekanst --- src/math/mat.zig | 2 +- src/math/quat.zig | 2 +- src/math/vec.zig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/math/mat.zig b/src/math/mat.zig index 9d5a73fb..bec09443 100644 --- a/src/math/mat.zig +++ b/src/math/mat.zig @@ -10,7 +10,7 @@ pub fn Mat( comptime n_rows: usize, comptime Vector: type, ) type { - return struct { + return extern struct { v: [cols]Vec, /// The number of columns, e.g. Mat3x4.cols == 3 diff --git a/src/math/quat.zig b/src/math/quat.zig index 3986576f..c5c09648 100644 --- a/src/math/quat.zig +++ b/src/math/quat.zig @@ -6,7 +6,7 @@ const math = mach.math; const vec = @import("vec.zig"); pub fn Quat(comptime Scalar: type) type { - return struct { + return extern struct { v: vec.Vec(4, Scalar), /// The scalar type of this matrix, e.g. Mat3x3.T == f32 diff --git a/src/math/vec.zig b/src/math/vec.zig index bc6959e1..8114fa18 100644 --- a/src/math/vec.zig +++ b/src/math/vec.zig @@ -5,7 +5,7 @@ const testing = mach.testing; const math = mach.math; pub fn Vec(comptime n_value: usize, comptime Scalar: type) type { - return struct { + return extern struct { v: Vector, /// The vector dimension size, e.g. Vec3.n == 3