int wmain(int argc, wchar_t *argv[], wchar_t *envp[]) { int i; lock_low32(); for (i=0; i<argc; i++) { // write the command line to UTF8 wchar_t *warg = argv[i]; size_t len = WideCharToMultiByte(CP_UTF8, 0, warg, -1, NULL, 0, NULL, NULL); if (!len) return 1; char *arg = (char*)alloca(len); if (!WideCharToMultiByte(CP_UTF8, 0, warg, -1, arg, len, NULL, NULL)) return 1; argv[i] = (wchar_t*)arg; } #endif #ifdef JULIA_ENABLE_THREADING // We need to make sure this function is called before any reference to // TLS variables. Since the compiler is free to move calls to // `jl_get_ptls_states()` around, we should avoid referencing TLS // variables in this function. (Mark `true_main` as noinline for this // reason). jl_set_ptls_states_getter(jl_get_ptls_states_static); #endif libsupport_init(); parse_opts(&argc, (char***)&argv); if (lisp_prompt) { jl_lisp_prompt(); return 0; } julia_init(imagepathspecified ? JL_IMAGE_CWD : JL_IMAGE_JULIA_HOME); int ret = true_main(argc, (char**)argv); jl_atexit_hook(ret); return ret; }
int main(int argc, char *argv[]) { #else int wmain(int argc, wchar_t *argv[], wchar_t *envp[]) { int i; for (i=0; i<argc; i++) { // write the command line to UTF8 wchar_t *warg = argv[i]; size_t wlen = wcslen(warg)+1; size_t len = WideCharToMultiByte(CP_UTF8, 0, warg, wlen, NULL, 0, NULL, NULL); if (!len) return 1; char *arg = (char*)alloca(len); if (!WideCharToMultiByte(CP_UTF8, 0, warg, wlen, arg, len, NULL, NULL)) return 1; argv[i] = (wchar_t*)arg; } #endif libsupport_init(); parse_opts(&argc, (char***)&argv); if (lisp_prompt) { jl_lisp_prompt(); return 0; } julia_init(imagepathspecified ? JL_IMAGE_CWD : JL_IMAGE_JULIA_HOME); int ret = true_main(argc, (char**)argv); jl_atexit_hook(); julia_save(); return ret; }
extern "C" int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, UINT) try { true_main (); return 0; } catch (std::exception& e) { auto w_what = Rk::string_utf8_to_16 (e.what ()); MessageBoxW (nullptr, (LPCWSTR) w_what.c_str (), L"Adventure", MB_ICONEXCLAMATION | MB_OK); return 1; }
int main () { try {true_main ();} catch (MyException* error) { error -> Report(stdout); delete error; } catch (int error) { printf ("%d\n", error); } catch (...) { printf ("Unknown type of error\n"); } return 0; }