Skip to content

Commit

Permalink
Use a different mechanism for passing the user main to al_run_main.
Browse files Browse the repository at this point in the history
This one doesn't crash on MacOS when using bundles.

Fixes #56
  • Loading branch information
SiegeLordEx authored and SiegeLord committed Oct 31, 2024
1 parent 54ce16e commit 0beabc3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions allegro5/system.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ extern (C) void rt_moduleTlsDtor();

int al_run_allegro(scope int delegate() user_main)
{
__gshared int delegate() user_main_inner;
user_main_inner = user_main;
extern(C) static int main_runner(int argc, char** argv)
{
version(OSX)
Expand All @@ -21,7 +23,7 @@ int al_run_allegro(scope int delegate() user_main)
rt_moduleTlsCtor();
}

auto main_ret = (*cast(int delegate()*)argv[0])();
auto main_ret = user_main_inner();

version(OSX)
{
Expand All @@ -32,8 +34,7 @@ int al_run_allegro(scope int delegate() user_main)
return main_ret;
}

char* fake_arg = cast(char*)&user_main;
return al_run_main(0, &fake_arg, &main_runner);
return al_run_main(0, null, &main_runner);
}

nothrow @nogc extern (C)
Expand Down

0 comments on commit 0beabc3

Please sign in to comment.