#How do I use a module which is defined at runtime in a function?

1 messages · Page 1 of 1 (latest)

frosty phoenix
#

As the title says, I will provide code later

hollow onyx
#

What is a module in this case

frosty phoenix
hollow onyx
#

You can't define a module at runtime

frosty phoenix
#

Oh

hollow onyx
#

A module, for the purposes of zig code, is just a namespace with its own import table, which is just a struct type

frosty phoenix
hollow onyx
#

What are you trying to do?

#

As in, what problem are you attempting to solve?

frosty phoenix
# hollow onyx What are you trying to do?

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

hollow onyx
#

Pretty sure you can just write zig uefi applications

frosty phoenix
hollow onyx
#

There's a whole uefi namespace in stdlib

frosty phoenix
#

uefi is just std.os.uefi

hollow onyx
#

What do you mean? Do you mean it's a var?

#

That just means it's a global var

frosty phoenix
hollow onyx
#

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

frosty phoenix
hollow onyx
#

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?

frosty phoenix
#

im doing it in main

hollow onyx
#

Well then the question again comes, what's the issue?

#

It should just work

frosty phoenix