Hi!
I have an image represented by an array of u8 (size is variable, depends on the file) and I try to define a function (within a struct) which takes embedded file as parameter. But as the size is unknown, I cannot get the compiler to agree 🙂
// global
const sprite_b = @embedFile("assets/logo_281x119.raw");
var big_sprite: Sprite = Sprite.init(fb, sprite_b, sprite_width, sprite_height, sprite_xoffset, sprite_yoffset);
pub const Sprite = struct {
fb: *LogicalFB = undefined,
width: u16 = undefined,
height: u16 = undefined,
x_offset: u16 = undefined,
y_offset: u16 = undefined,
data: *const []u8 = undefined,
pub fn init(fb: *LogicalFB, data: *const []u8, width: u16, height: u16, x_offset: u16, y_offset: u16) Sprite {
...
Error:
error: expected type '*const []u8', found '*const [33439:0]u8'
var big_sprite: Sprite = Sprite.init(fb, sprite_b, sprite_width, sprite_height, sprite_xoffset, sprite_yoffset);
^~~~~~~~
C:\Perso\projects\ZigMachine\demo.zig:110:50: note: pointer type child 'u8' cannot cast into pointer type child '[]u8'
How data should be defined?
Thanks!