Skip to content

Instantly share code, notes, and snippets.

@laytan
Created June 30, 2024 21:11
Show Gist options
  • Save laytan/9995c24253495be5dad4878ff24be637 to your computer and use it in GitHub Desktop.
Save laytan/9995c24253495be5dad4878ff24be637 to your computer and use it in GitHub Desktop.
Odin with C entry point
int odin_main(int argc, char *argv[]);
int main(int argc, char *argv[])
{
return odin_main(argc, argv);
}
program: entry.c program.odin
odin build . -out:program -no-entry-point -build-mode:object
clang entry.c program.o -o program
rm program.o
package main
import "base:runtime"
import "core:fmt"
import "core:os"
@(export)
odin_main :: proc "c" (argc: i32, argv: [^]cstring) -> i32 {
runtime.args__ = argv[:argc]
context = runtime.default_context()
#force_no_inline runtime._startup_runtime()
main()
#force_no_inline runtime._cleanup_runtime()
return 0
}
message: string
@(init)
init_message :: proc() {
message = "Hellope!"
}
main :: proc() {
fmt.println(message, os.args)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment