Created
June 30, 2024 21:11
-
-
Save laytan/9995c24253495be5dad4878ff24be637 to your computer and use it in GitHub Desktop.
Odin with C entry point
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int odin_main(int argc, char *argv[]); | |
int main(int argc, char *argv[]) | |
{ | |
return odin_main(argc, argv); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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