Im having a general problem with how to translate Cs
#define FOO "bar"
and then being able to access this from any file
Lets imagine this file structure:
src/
|-a.zig
|-b.zig
|-utils/
| |-utils.zig
a and b are 2 different programs and the shared utilities are in utils.zig
A and B both have a common list of properties that need be defined, and if they dont define them then theres either a fallback value defined in utils or it skips parts of code (classic #ifdef)
Well, the closest i was to be able to have this is add some utils/globals.zig, with a bunch of
pub var FOO = "var";
Import it in the program files and redefine it, but first problem, they arent globals there, they need to be redefined at least inside main, and then also, even if the values are comptime known, the compiler strictly considers them runtime
A more real case:
In GNUs coreutils theres the program true, which returns a success status, and theres false, which returns a failure status. The program itself is actually written in true, and false just changes the #define EXIT_STATUS
So in true.c it uses the defined value of EXIT_STATUS for conditionally building what the program name is and what the help message says, etc. All that is comptime known, but in zig i cant find a way to get this behaviour
I feel like this question is a bit disorganized and i think thats because the macro system does so much different stuff that im a bit lost with all the questions that arise of how to translate it. Sorry in advance.