blob: 85bbfbcd216aeb260b8ecb3cf78a8af4868e2ce7 [file] [log] [blame]
Bram Moolenaaredf3f972016-08-29 22:49:24 +02001/* vi:set ts=8 sts=4 sw=4 noet:
Bram Moolenaar071d4272004-06-13 20:20:40 +00002 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 * GUI support by Robert Webb
5 *
6 * Do ":help uganda" in Vim to read copying and usage conditions.
7 * Do ":help credits" in Vim to see a list of people who contributed.
8 * See README.txt for an overview of the Vim source code.
9 */
10/*
Ken Takatab32d0a42024-07-26 18:46:54 +020011 * Windows GUI/Console: main program (EXE) entry point:
Bram Moolenaar071d4272004-06-13 20:20:40 +000012 *
Ken Takatab32d0a42024-07-26 18:46:54 +020013 * Ron Aaron <ronaharon@yahoo.com> wrote this and the DLL support code.
14 * Adapted by Ken Takata.
Bram Moolenaar071d4272004-06-13 20:20:40 +000015 */
16#include "vim.h"
17
Bram Moolenaarb26705a2019-04-02 22:02:32 +020018// cproto doesn't create a prototype for VimMain()
Bram Moolenaarafde13b2019-04-28 19:46:49 +020019#ifdef VIMDLL
20__declspec(dllimport)
21#endif
Bram Moolenaareae1b912019-05-09 15:12:55 +020022int VimMain(int argc, char **argv);
Ken Takatab32d0a42024-07-26 18:46:54 +020023
24#ifdef VIMDLL
25# define SaveInst(hInst) // Do nothing
26#else
Bram Moolenaareae1b912019-05-09 15:12:55 +020027void SaveInst(HINSTANCE hInst);
Bram Moolenaar071d4272004-06-13 20:20:40 +000028#endif
29
Ken Takatab32d0a42024-07-26 18:46:54 +020030#ifdef FEAT_GUI
Bram Moolenaar071d4272004-06-13 20:20:40 +000031 int WINAPI
Bram Moolenaar796cc422019-04-03 20:31:00 +020032wWinMain(
Bram Moolenaarb26705a2019-04-02 22:02:32 +020033 HINSTANCE hInstance,
Bram Moolenaar1266d672017-02-01 13:43:36 +010034 HINSTANCE hPrevInst UNUSED,
Bram Moolenaar796cc422019-04-03 20:31:00 +020035 LPWSTR lpszCmdLine UNUSED,
Bram Moolenaar1266d672017-02-01 13:43:36 +010036 int nCmdShow UNUSED)
Ken Takatab32d0a42024-07-26 18:46:54 +020037{
38 SaveInst(hInstance);
39 return VimMain(0, NULL);
40}
41#else
Bram Moolenaar796cc422019-04-03 20:31:00 +020042 int
43wmain(int argc UNUSED, wchar_t **argv UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000044{
Bram Moolenaarafde13b2019-04-28 19:46:49 +020045 SaveInst(GetModuleHandleW(NULL));
Ken Takatab32d0a42024-07-26 18:46:54 +020046 return VimMain(0, NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +000047}
48#endif
Ken Takatab32d0a42024-07-26 18:46:54 +020049
50#ifdef USE_OWNSTARTUP
51// Use our own entry point and don't use the default CRT startup code to
52// reduce the size of (g)vim.exe. This works only when VIMDLL is defined.
53//
54// For MSVC, the /GS- compiler option is needed to avoid the undefined symbol
55// error. (It disables the security check. However, it affects only this
56// function and doesn't have any effect on Vim itself.)
57// For MinGW, the -nostdlib compiler option and the --entry linker option are
58// needed.
59# ifdef FEAT_GUI
60 void WINAPI
61wWinMainCRTStartup(void)
62{
63 VimMain(0, NULL);
64}
65# else
66 void
67wmainCRTStartup(void)
68{
69 VimMain(0, NULL);
70}
71# endif
72#endif // USE_OWNSTARTUP