Replies: 2 comments 1 reply
-
@Kelimion do you concur? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Another take on a possible change. Main idea is to have a unified system for compile-time/runtime linking libraries with a single set of symbol definitions. // some_lib/bindings/bindings.odin
package some_lib_bindings
bindings: runtime.Bindings
// in one place
bindings {
some_func: proc(),
}
// in another, possibly in another file
@(link_prefix="some_")
bindings {
other_func: proc(),
} Example 1; comptime// some_lib/some_lib.odin
package some_lib
import "bindings"
foreign import "some_lib.dll"
// This presumably imports all of the symbols into this package for access, or something like that
#foreign_bind(some_lib, &bindings.bindings) Example 2; runtimeNote: there has to be a way to iterate through // my_program/main.odin
package main
import some_lib_runtime "some_lib/bindings"
main :: proc() {
some_lib := dynlib.load("some_lib.dll")
ok := dynlib.bind(&some_lib, &some_lib_runtime.bindings)
// NOTE: ok signifies if *all* symbols were loaded, mirroring comptime binding; to handle individual symbols missing - you can write your own binding function
{ // in this scope you can pretend to be working with a library as usual; you can do it at global scope as well
some_lib :: some_lib_runtime.bindings
some_lib.some_func()
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Example:
To figure out if the library was loaded:
intrinsic.was_foreign_import_loaded(dynamic_module.dll_name)
Beta Was this translation helpful? Give feedback.
All reactions