From 096125d963400951e0f160ced86416ef8c9c98b0 Mon Sep 17 00:00:00 2001 From: grischka Date: Sat, 18 Feb 2017 09:51:23 +0100 Subject: win32: adjust new unicode support - lib/Makefile: add (win)crt1_w.o - crt1.c/_runtmain: return to tcc & only use for UNICODE (because it might be not 100% reliable with for example wildcards (tcc *.c -run ...) - tccrun.c/tccpe.c: load -run startup_code only if called from tcc_run(). Otherwise main may not be defined. See libtcc_test.c - tests2/Makefile: pass extra options in FLAGS to allow overriding TCC Also: - tccpe.c: support weak attribute. (I first tried to solve the problem above by using it but then didn't) --- win32/lib/crt1.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'win32/lib/crt1.c') diff --git a/win32/lib/crt1.c b/win32/lib/crt1.c index 1e2bd17..a9b1a30 100644 --- a/win32/lib/crt1.c +++ b/win32/lib/crt1.c @@ -65,24 +65,23 @@ void _tstart(void) exit(ret); } -void _runtmain(int argc0, /* as tcc passed in */ char **argv0) +int _runtmain(int argc, /* as tcc passed in */ char **argv) { - __TRY__ - int argc, ret; - _TCHAR **argv; - _TCHAR **env; - _startupinfo start_info; - - __set_app_type(_CONSOLE_APP); +#ifdef UNICODE + int wargc; + _TCHAR **wargv, **wenv; + _startupinfo start_info = {0}; + + __tgetmainargs(&wargc, &wargv, &wenv, _dowildcard, &start_info); + if (argc < wargc) + wargv += wargc - argc; +#define argv wargv +#endif #ifdef __i386 _controlfp(_PC_53, _MCW_PC); #endif - - start_info.newmode = 0; - __tgetmainargs( &argc, &argv, &env, _dowildcard, &start_info); - ret = _tmain(argc0, argv + argc - argc0, env); - exit(ret); + return _tmain(argc, argv, NULL); } // ============================================= -- cgit v1.3.1