aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-09-30 11:20:35 +0100
committerGinger Bill <bill@gingerbill.org>2017-09-30 11:20:35 +0100
commite2b9c87aa888da76d6bd366fd99d0c8d2d99e756 (patch)
tree14ab0844822d2be0b7cdd2ace768d73ceb8d4310 /core
parent8c7cf0dbb0b4cf9730788c619c8cb9adf8f284a1 (diff)
Wrap entry point `main` around the C style `main` in the IR
Diffstat (limited to 'core')
-rw-r--r--core/_preload.odin2
-rw-r--r--core/os_linux.odin7
-rw-r--r--core/os_x.odin12
3 files changed, 17 insertions, 4 deletions
diff --git a/core/_preload.odin b/core/_preload.odin
index 014a3c219..3a921e750 100644
--- a/core/_preload.odin
+++ b/core/_preload.odin
@@ -138,8 +138,8 @@ Type_Info :: struct #ordered {
// This will be set by the compiler
__type_table: []Type_Info;
-__argv__: ^^u8;
__argc__: i32;
+__argv__: ^^u8;
// IMPORTANT NOTE(bill): Must be in this order (as the compiler relies upon it)
diff --git a/core/os_linux.odin b/core/os_linux.odin
index afbd41f7c..3a4a8d6cf 100644
--- a/core/os_linux.odin
+++ b/core/os_linux.odin
@@ -267,6 +267,9 @@ dlerror :: proc() -> string {
_alloc_command_line_arguments :: proc() -> []string {
- // TODO(bill):
- return nil;
+ args := make([]string, __argc__);
+ for i in 0..__argc__ {
+ args[i] = strings.to_odin_string((__argv__+i)^);
+ }
+ return args;
}
diff --git a/core/os_x.odin b/core/os_x.odin
index ad267e22a..1f41bd884 100644
--- a/core/os_x.odin
+++ b/core/os_x.odin
@@ -42,7 +42,8 @@ RTLD_NOLOAD :: 0x10;
RTLD_FIRST :: 0x100;
-args: [dynamic]string;
+// "Argv" arguments converted to Odin strings
+args := _alloc_command_line_arguments();
_File_Time :: struct #ordered {
seconds: i64,
@@ -279,3 +280,12 @@ dlclose :: proc(handle: rawptr) -> bool #inline {
dlerror :: proc() -> string {
return strings.to_odin_string(unix_dlerror());
}
+
+
+_alloc_command_line_arguments :: proc() -> []string {
+ args := make([]string, __argc__);
+ for i in 0..__argc__ {
+ args[i] = strings.to_odin_string((__argv__+i)^);
+ }
+ return args;
+}