aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-17 18:21:20 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-17 18:21:20 +0200
commit91f56e45665e0ae940553acc1d0013adec970712 (patch)
treeb79a7db869ca0f73ae1b42fede7b51ce076a35e6 /c
parent412d3fb1dca2255b53f5fad83d38b4cb06af2972 (diff)
downloadEpisodeBrowser-91f56e45665e0ae940553acc1d0013adec970712.tar.gz
Install terminate handler before initialization of globals.
Diffstat (limited to 'c')
-rw-r--r--c/main.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/c/main.cpp b/c/main.cpp
index 7f7ea9b..7a3e6a2 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -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)))