文件
Paze-C-CPP-Compiler/win32/lib/wincrt1.c
T
Paze AI 251ee470bf feat: Paze C Compiler - 完整改造自 tcc 0.9.28rc
- 所有 tcc 文件/内容/宏改名为 pcc (tcc.c->pcc.c, tccelf.c->pccelf.c, libtcc.c->libpcc.c 等)
- 支持架构: i386, x86_64, ARM, ARM64, RISC-V, C67
- 支持格式: PE, ELF, Mach-O, COFF
- 完整预处理、代码生成、链接器、调试信息
- 构建成功: pcc.exe (x86_64 Windows)
- 功能测试通过: 递归/结构体/浮点/switch/循环
- 自编译测试通过: pcc 可以编译自身
2026-08-16 13:30:01 +08:00

87 行
2.2 KiB
C

//+---------------------------------------------------------------------------
// _UNICODE for tchar.h, UNICODE for API
#include <tchar.h>
#include <windows.h>
#include <stdlib.h>
#define __UNKNOWN_APP 0
#define __CONSOLE_APP 1
#define __GUI_APP 2
void __set_app_type(int);
void _controlfp(unsigned a, unsigned b);
#ifdef _UNICODE
#define __tgetmainargs __wgetmainargs
#define _twinstart _wwinstart
#define _runtwinmain _runwwinmain
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
#else
#define __tgetmainargs __getmainargs
#define _twinstart _winstart
#define _runtwinmain _runwinmain
#endif
typedef struct { int newmode; } _startupinfo;
int __cdecl __tgetmainargs(int *pargc, _TCHAR ***pargv, _TCHAR ***penv, int globb, _startupinfo*);
#include "crtinit.c"
static int go_winmain(TCHAR *arg1)
{
STARTUPINFO si;
_TCHAR *szCmd, *p;
int fShow;
int retval;
GetStartupInfo(&si);
if (si.dwFlags & STARTF_USESHOWWINDOW)
fShow = si.wShowWindow;
else
fShow = SW_SHOWDEFAULT;
szCmd = NULL, p = GetCommandLine();
if (arg1)
szCmd = _tcsstr(p, arg1);
if (NULL == szCmd)
szCmd = _tcsdup(__T(""));
else if (szCmd > p && szCmd[-1] == __T('"'))
--szCmd;
#if defined __i386__ || defined __x86_64__
_controlfp(0x10000, 0x30000);
#endif
run_ctors(__argc, __targv, _tenviron);
retval = _tWinMain(GetModuleHandle(NULL), NULL, szCmd, fShow);
run_dtors();
return retval;
}
static LONG WINAPI catch_sig(EXCEPTION_POINTERS *ex)
{
return _XcptFilter(ex->ExceptionRecord->ExceptionCode, ex);
}
int _twinstart(void)
{
_startupinfo start_info_con = {0};
SetUnhandledExceptionFilter(catch_sig);
__set_app_type(__GUI_APP);
__tgetmainargs(&__argc, &__targv, &_tenviron, 0, &start_info_con);
exit(go_winmain(__argc > 1 ? __targv[1] : NULL));
}
int _runtwinmain(int argc, /* as pcc passed in */ char **argv)
{
#ifdef UNICODE
_startupinfo start_info = {0};
__tgetmainargs(&__argc, &__targv, &_tenviron, 0, &start_info);
/* may be wrong when pcc has received wildcards (*.c) */
if (argc < __argc)
__targv += __argc - argc, __argc = argc;
#else
__argc = argc, __targv = argv;
#endif
return go_winmain(__argc > 1 ? __targv[1] : NULL);
}