diff --git a/compiler/fn.v b/compiler/fn.v index 54334ca30e..78300b3a62 100644 --- a/compiler/fn.v +++ b/compiler/fn.v @@ -345,10 +345,10 @@ fn (p mut Parser) fn_decl() { p.genln('init_consts();') if p.table.imports.contains('os') { if f.name == 'main' { - p.genln('os__init_os_args(argc, argv);') + p.genln('os__args = os__init_os_args(argc, argv);') } else if f.name == 'WinMain' { - p.genln('os__parse_windows_cmd_line(pCmdLine);') + p.genln('os__args = os__parse_windows_cmd_line(pCmdLine);') } } // We are in live code reload mode, call the .so loader in bg diff --git a/compiler/table.v b/compiler/table.v index 7b50e18de5..fb8f02318c 100644 --- a/compiler/table.v +++ b/compiler/table.v @@ -453,6 +453,9 @@ fn (p mut Parser) _check_types(got, expected string, throw bool) bool { if got.eq('int') && expected.eq('byte') { return true } + if got.eq('byteptr') && expected.eq('byte*') { + return true + } if got.eq('int') && expected.eq('byte*') { return true } diff --git a/os/os.v b/os/os.v index 7a069137f2..9cb1451a26 100644 --- a/os/os.v +++ b/os/os.v @@ -21,24 +21,21 @@ import const ( SEEK_END ) -fn init_os_args(argc int, c voidptr) []string { +fn init_os_args(argc int, _argv *byteptr) []string { mut args := []string - # char** argv = (char**) c; + # char** argv = (char**) _argv; for i := 0; i < argc; i++ { - // # printf("ARG %d = '%s'\n", i, argv[i]); arg := '' - # arg = tos(argv[i], strlen(argv[i])); + //arg := tos(argv[i], strlen(argv[i])) + # arg = tos((char**)(argv[i]), strlen((char**)(argv[i]))); args << arg } - # os__args = args; return args } -fn parse_windows_cmd_line(cmd byteptr) { +fn parse_windows_cmd_line(cmd byteptr) []string { s := tos2(cmd) - vals := s.split(' ') - println(vals) - # os__args = vals; + return s.split(' ') } fn C.ftell(fp voidptr) int