Void* (C) and *anyopaque (Zig)

Let it be like this:

pub fn opaqPtrTo(ptr: ?*anyopaque, comptime T: type) T {
    return @ptrCast(T, @alignCast(@alignOf(T), ptr));
}

fn workD0(me: *StageMachine, src: ?*StageMachine, dptr: ?*anyopaque) void {
    var io = opaqPtrTo(dptr, *EventSource);
    var pd = opaqPtrTo(me.data, *RxData);
    ...
}
1 Like

I like the name!
I wasn’t sure what to call it, so I just picked my first idea.

I also like the parameter order makes it quite nice to read and matches the function name.
I think keeping the * explicit is good for readability that way you don’t have to mentally add it back in when scanning over the code.

Yeah, my first version was ill-considered.