aboutsummaryrefslogtreecommitdiff
path: root/pd/src/s_entry.c
blob: 9a0984ed17b26afda84d08e9bef367a76d194ead (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* In MSW, this is all there is to pd; the rest sits in a "pdlib" dll so
that externs can link back to functions defined in pd. */

int sys_main(int argc, char **argv);

/* 
 * gcc does not support the __try stuff, only MSVC.  Also, MinGW allows you to
 * use main() instead of WinMain(). <hans@at.or.at>
 */
#if defined(_MSC_VER) && !defined(COMMANDVERSION)
#include <windows.h>
#include <stdio.h>

int WINAPI WinMain(HINSTANCE hInstance,
                               HINSTANCE hPrevInstance,
                               LPSTR lpCmdLine,
                               int nCmdShow)
{ 
    __try {
        sys_main(__argc,__argv);
    }
    __finally
    { 
        printf("caught an exception; stopping\n");
    }
    return (0);
}

#else /* not _MSC_VER ... */
int main(int argc, char **argv)
{
    return (sys_main(argc, argv));
}
#endif /* _MSC_VER */