Hey all, first time poster! Hoping y'all might be able to help with this comptime question.
I'm hoping to build a node-based audio system where users can bring their own processing structs and easily integrate them with other processing nodes, provided they stick to a few rules.
To that end, I'd like to provide a uniform way to access fields of arbitrary structs, where these fields are acting as inputs and outputs for node processing.
My general idea has been to check structs for field names that start with "in" and "out", and build a function that collates pointers to these fields for instances of these structs.
so, given some struct like:
const node: Node = .{
.in_one = "1",
.in_two = "2",
.in_three = "3",
.drive_in = "no",
.out_back = "yes",
.steak_house = "yum",
};
I could build some struct that could take this Node type, pull the field names in_one , in_two, and in_three by way of std.meta.fields(Node), and then build a function that can find the pointer offsets of these fields for an instance of Node at runtime, such that you'd get a tidy array holding pointers to your "in" fields.
I'm coming up against an issue where my comptime-built array of field names isn't playing nice with offsetOf(Node, name) at runtime, yielding the error:
no offset available for comptime field
const offset = @offsetOf(T, name);
Would appreciate any advice/pointers!