Skip to content

Instantly share code, notes, and snippets.

@alvivi
Created February 22, 2011 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvivi/839329 to your computer and use it in GitHub Desktop.
Save alvivi/839329 to your computer and use it in GitHub Desktop.
c_main.c
#include <stdio.h>
#include "HsFFI.h"
#ifdef __APPLE__
#include <objc/objc.h>
#include <objc/objc-runtime.h>
#endif
#include <SDL.h>
#ifdef __GLASGOW_HASKELL__
#include "HSMain_stub.h"
extern void __stginit_HSMain ( void );
#endif
int SDL_main(int argc, char *argv[])
{
int i;
#ifdef __APPLE__
void * pool =
objc_msgSend(objc_lookUpClass("NSAutoreleasePool"), sel_getUid("alloc"));
objc_msgSend(pool, sel_getUid("init"));
#endif
hs_init(&argc, &argv);
#ifdef __GLASGOW_HASKELL__
hs_add_root(__stginit_HSMain);
#endif
hs_main();
hs_exit();
#ifdef __APPLE__
objc_msgSend(pool, sel_getUid("release"));
#endif
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment