I’m getting my feet wet in zig with a toy game project. As is it very early, I end up with lots of compilation time values.
Is there an idiomatic way to make those available to a debugger (e.g. RAD Debugger, RemedyBG), i.e. in a watch window expression or usable in a conditional breakpoint.
I expect I would have to write something in code, because if it’s not used, it’s not compiled so it doesn’t have a value, but could I force the evaluation by giving some function a type (e.g. main), and all the value constants of that type would be returned as variables in a new struct type.
Is there already something in the lib that would have the same effect?
Then you can put _r in the watch window to observe your pub const of the root.zig file, so you can observe your non-trivial comptime values more easily, without a printf-compile loop.
That is near, but I’m curious as to what you are doing that makes that easier than using std.debug.print or @compileLog. ofc if you learnt something then it’s certainly worth it.
Nothing special. I just started my project and had some segfault and wanted to reason about my index arithmetic, what value wasn’t what I expected, I don’t remember the details.
My main question was how people in the community usually go about it: many pub var, write a test to show the values, std.debug.print the values, some debugging feature I don’t know about, some compiler output that can be enable.
I thought of this solution because I didn’t want to keep track of my symbols in more than one place (i.e. where I need it for compilation + where I need make it observable at runtime), and I didn’t want to lose the comptime just to observe it in a debugger. Now I need to put the struct in a variable and do the std.mem call and add pub to the const, but it’s good enough for me as I expect the project structure will not change as much as adding/removing/renaming const.