diff options
author | John Ankarström <john@ankarstrom.se> | 2022-08-17 18:21:20 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-08-17 18:21:20 +0200 |
commit | 91f56e45665e0ae940553acc1d0013adec970712 (patch) | |
tree | b79a7db869ca0f73ae1b42fede7b51ce076a35e6 | |
parent | 412d3fb1dca2255b53f5fad83d38b4cb06af2972 (diff) | |
download | EpisodeBrowser-91f56e45665e0ae940553acc1d0013adec970712.tar.gz |
Install terminate handler before initialization of globals.
-rw-r--r-- | c/main.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -21,6 +21,10 @@ #define YMAIN CW_USEDEFAULT #endif +/* Exit gracefully on uncaught exception. */ +static void OnTerminate() noexcept; +static auto unused = std::set_terminate(OnTerminate); + /* main.cpp defines all global (non-template) variables used in the * program. `extern' is used to access them from other files, when * need be. */ @@ -72,7 +76,7 @@ static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM); /* Try to style application according to current Windows theme. */ static void UpdateTheme(); -static void OnTerminate() noexcept +void OnTerminate() noexcept { const wchar_t* what = L"an exception"; WcharPtr why; @@ -104,9 +108,6 @@ int WINAPI WinMain(const HINSTANCE hInstance, const HINSTANCE, char* const, cons { setbuf(stdout, nullptr); - /* Exit gracefully on uncaught exception. */ - std::set_terminate(OnTerminate); - /* Initialize Prolog. */ const char* argv[] = {"EpisodeBrowser", nullptr}; if (!PL_initialise(1, const_cast<char**>(argv))) |