aboutsummaryrefslogtreecommitdiff
path: root/win32/lib/crt1.c
diff options
context:
space:
mode:
authorCarlos Montiers <carlos@thefunsouth.com>2014-11-22 19:00:49 -0300
committerCarlos Montiers <carlos@thefunsouth.com>2014-11-22 19:00:49 -0300
commitf40b82295ec3d4cb35d2b660880fee768aee0299 (patch)
tree1e61b26a31d61b2ad0f2375d72d3814a243c9104 /win32/lib/crt1.c
parent1e07ea71d3f564beb7f71dd868499eef996ffbae (diff)
downloadtinycc-f40b82295ec3d4cb35d2b660880fee768aee0299.tar.gz
tinycc-f40b82295ec3d4cb35d2b660880fee768aee0299.tar.bz2
__getmainargs compatibility checking success
Diffstat (limited to 'win32/lib/crt1.c')
-rw-r--r--win32/lib/crt1.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/win32/lib/crt1.c b/win32/lib/crt1.c
index 0be446f..eb2a7b5 100644
--- a/win32/lib/crt1.c
+++ b/win32/lib/crt1.c
@@ -16,28 +16,32 @@ typedef struct
int newmode;
} _startupinfo;
-int __getmainargs(int *pargc, char ***pargv, char ***penv, int globb, _startupinfo*);
+// prototype of __getmainargs:
+// in msvcrt v6.0 : return void
+// in msvcrt v7.0 : return int
+// using first for compatibility
+void __getmainargs(int *pargc, char ***pargv, char ***penv, int globb, _startupinfo*);
int main(int argc, char **argv, char **env);
int _start(void)
{
__TRY__
- int argc; char **argv; char **env;
+ int argc; char **argv; char **env; int ret;
_startupinfo start_info = {0};
_controlfp(0x10000, 0x30000);
__set_app_type(__CONSOLE_APP);
- if (! __getmainargs(&argc, &argv, &env, 0, &start_info))
+ argv = NULL;
+ __getmainargs(&argc, &argv, &env, 0, &start_info);
+ // check success comparing if argv now is not NULL
+ if (! argv)
{
- int ret;
-
- ret = main(argc, argv, env);
- exit(ret);
+ ExitProcess(-1);
}
- // __getmainargs failed because possible few memory on the heap.
- // end with exit code of 3, similar to abort()
- ExitProcess(3);
+
+ ret = main(argc, argv, env);
+ exit(ret);
}
// =============================================