diff --git a/compiler/main.v b/compiler/main.v index f2306f1744..3f5b6d22ee 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -388,8 +388,19 @@ void init_consts();') cgen.lines.set(defs_pos, dd)// TODO `def.str()` doesn't compile // if v.build_mode in [.default, .embed_vlib] { if v.pref.build_mode == .default_mode || v.pref.build_mode == .embed_vlib { + mut consts_init_body := cgen.consts_init.join_lines() + for imp in v.table.imports { + if imp == 'http' { + consts_init_body += '\n http__init_module();' + } + } // vlib can't have `init_consts()` - cgen.genln('void init_consts() { \n#ifdef _WIN32\n _setmode(_fileno(stdout), _O_U8TEXT); \nSetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), ENABLE_PROCESSED_OUTPUT | 0x0004); // ENABLE_VIRTUAL_TERMINAL_PROCESSING\n#endif\n g_str_buf=malloc(1000); ${cgen.consts_init.join_lines()} }') + cgen.genln('void init_consts() { +#ifdef _WIN32\n _setmode(_fileno(stdout), _O_U8TEXT); +SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), ENABLE_PROCESSED_OUTPUT | 0x0004); +// ENABLE_VIRTUAL_TERMINAL_PROCESSING\n#endif\n g_str_buf=malloc(1000); +$consts_init_body +}') // _STR function can't be defined in vlib cgen.genln(' string _STR(const char *fmt, ...) { diff --git a/vlib/http/openssl_backend.v b/vlib/http/openssl_backend.v index b932ae96ff..99c19f3d53 100644 --- a/vlib/http/openssl_backend.v +++ b/vlib/http/openssl_backend.v @@ -16,17 +16,12 @@ struct C.SSL { } fn init_module() { - init_openssl() -} - -fn init_openssl() { C.SSL_library_init() //C.SSL_load_error_strings() //C.OPENSSL_config(0) } fn ssl_do(method, host_name, path string) string { - init_openssl() ssl_method := C.SSLv23_method() if isnil(method) { }