String literals are always const
[tinycc.git] / win32 / lib / crt1.c
blob2cb25c00abfab4e48af1f18b01f1149b66edaab0
1 // =============================================
2 // crt1.c
4 // _UNICODE for tchar.h, UNICODE for API
5 #include <tchar.h>
7 #include <stdio.h>
8 #include <stdlib.h>
10 #define _UNKNOWN_APP 0
11 #define _CONSOLE_APP 1
12 #define _GUI_APP 2
14 #define _MCW_PC 0x00030000 // Precision Control
15 #define _PC_24 0x00020000 // 24 bits
16 #define _PC_53 0x00010000 // 53 bits
17 #define _PC_64 0x00000000 // 64 bits
19 typedef struct
21 int newmode;
22 } _startupinfo;
24 #ifdef _UNICODE
25 #define __tgetmainargs __wgetmainargs
26 #define _tstart _wstart
27 #define _tmain wmain
28 #define _runtmain _runwmain
29 #else
30 #define __tgetmainargs __getmainargs
31 #define _tstart _start
32 #define _tmain main
33 #define _runtmain _runmain
34 #endif
36 int __cdecl __tgetmainargs(int *pargc, _TCHAR ***pargv, _TCHAR ***penv, int globb, _startupinfo*);
37 void __cdecl __set_app_type(int apptype);
38 unsigned int __cdecl _controlfp(unsigned int new_value, unsigned int mask);
39 extern int _tmain(int argc, _TCHAR * argv[], _TCHAR * env[]);
41 /* Allow command-line globbing with "int _dowildcard = 1;" in the user source */
42 int _dowildcard;
44 void _tstart(void)
46 __TRY__
47 int argc, ret;
48 _TCHAR **argv;
49 _TCHAR **env;
50 _startupinfo start_info;
52 // Sets the current application type
53 __set_app_type(_CONSOLE_APP);
55 // Set default FP precision to 53 bits (8-byte double)
56 // _MCW_PC (Precision control) is not supported on
57 // the ARM and x64 architectures
58 #ifdef __i386
59 _controlfp(_PC_53, _MCW_PC);
60 #endif
62 start_info.newmode = 0;
63 __tgetmainargs( &argc, &argv, &env, _dowildcard, &start_info);
64 ret = _tmain(argc, argv, env);
65 exit(ret);
68 int _runtmain(int argc, /* as tcc passed in */ char **argv)
70 #ifdef UNICODE
71 int wargc;
72 _TCHAR **wargv, **wenv;
73 _startupinfo start_info = {0};
75 __tgetmainargs(&wargc, &wargv, &wenv, _dowildcard, &start_info);
76 /* may be wrong when tcc has received wildcards (*.c) */
77 if (argc < wargc)
78 wargv += wargc - argc;
79 else
80 argc = wargc;
81 #define argv wargv
82 #endif
84 #ifdef __i386
85 _controlfp(_PC_53, _MCW_PC);
86 #endif
87 return _tmain(argc, argv, _tenviron);
90 // =============================================