#How do I use a module which is defined at runtime in a function?
1 messages · Page 1 of 1 (latest)
What is a module in this case
Something like std or such that contains functions
You can't define a module at runtime
Oh
A module, for the purposes of zig code, is just a namespace with its own import table, which is just a struct type
Ye I'm kinda new to zig lol
I wanted to see if I could use zig to write UEFI applications cause dealing with linking something like gnu-efi was annoying, I want to use UEFI's con_out in a function
Pretty sure you can just write zig uefi applications
That's what I'm doing
There's a whole uefi namespace in stdlib
That is what I'm using, but uefi.system_table.con_out is defined at runtime
uefi is just std.os.uefi
It's a const, but it's not comptime, it's runtime
Like extern const?
If you just mean a plain const, it can't be defined at runtime if it's global, internal zig globals are always initialized at comptime
this
What's the problem
That's a var which is assigned before main is called, in start.zig
So by the time you reference it, it should already be defined, unless you've overriden main
Oh I think I know what your problem is
Are you declaring const con_out outside of a function @frosty phoenix?
Or rather, inside a struct or in the file namespace?
no
im doing it in main
i got it working by just using the full uefi.system_table part in the function