#error: expected type '*memory.Memory', found '*const memory.Memory'

1 messages · Page 1 of 1 (latest)

plush tapir
#

I get this when calling a function from another type, eg:

cpu.zig:134:23: error: expected type '*memory.Memory', found '*const memory.Memory'
            cpu.memory.write(ram.address, ram.value);
            ~~~~~~~~~~^~~~~~

Memory is declared as pub const Memory = struct {} and the referenced method signature is:

pub fn write(self: *Memory, address: u16, value: u8) void

Memory init is: pub fn init(allocator: Allocator) !Memory

What am I doing wrong?

dusty ferry
#

&v gets you a *const @TypeOf(v), a const pointer to v, when you have const v
You need var v

plush tapir
#

Oh, it's my cpu which needs to be a var