diff --git a/glib/gbacktrace.c b/glib/gbacktrace.c index 3b3b0eacb..86f884170 100644 --- a/glib/gbacktrace.c +++ b/glib/gbacktrace.c @@ -192,9 +192,16 @@ g_on_error_query (const gchar *prg_name) if (!prg_name) prg_name = g_get_prgname (); + /* MessageBox is allowed on UWP apps only when building against + * the debug CRT, which will set -D_DEBUG */ +#if defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP) MessageBox (NULL, "g_on_error_query called, program terminating", (prg_name && *prg_name) ? prg_name : NULL, MB_OK|MB_ICONERROR); +#else + printf ("g_on_error_query called, program '%s' terminating\n", + (prg_name && *prg_name) ? prg_name : "(null)"); +#endif _exit(0); #endif } diff --git a/glib/gmessages.c b/glib/gmessages.c index 591185605..bb1ab8f84 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -1358,7 +1358,9 @@ g_logv (const gchar *log_domain, if ((test_level & G_LOG_FLAG_FATAL) && !masquerade_fatal) { -#ifdef G_OS_WIN32 + /* MessageBox is allowed on UWP apps only when building against + * the debug CRT, which will set -D_DEBUG */ +#if defined(G_OS_WIN32) && (defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP)) if (win32_keep_fatal_message) { gchar *locale_msg = g_locale_from_utf8 (fatal_msg_buf, -1, NULL, NULL, NULL); @@ -1366,7 +1368,7 @@ g_logv (const gchar *log_domain, MessageBox (NULL, locale_msg, NULL, MB_ICONERROR|MB_SETFOREGROUND); } -#endif /* !G_OS_WIN32 */ +#endif _g_log_abort (!(test_level & G_LOG_FLAG_RECURSION)); } @@ -2675,7 +2677,9 @@ handled: /* Abort if the message was fatal. */ if (log_level & G_LOG_FLAG_FATAL) { -#ifdef G_OS_WIN32 + /* MessageBox is allowed on UWP apps only when building against + * the debug CRT, which will set -D_DEBUG */ +#if defined(G_OS_WIN32) && (defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP)) if (!g_test_initialized ()) { gchar *locale_msg = NULL; diff --git a/glib/gutils.c b/glib/gutils.c index 62a64d912..988d0a599 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -95,28 +95,6 @@ #ifdef G_OS_WIN32 # include # include - /* older SDK (e.g. msvc 5.0) does not have these*/ -# ifndef CSIDL_MYMUSIC -# define CSIDL_MYMUSIC 13 -# endif -# ifndef CSIDL_MYVIDEO -# define CSIDL_MYVIDEO 14 -# endif -# ifndef CSIDL_INTERNET_CACHE -# define CSIDL_INTERNET_CACHE 32 -# endif -# ifndef CSIDL_COMMON_APPDATA -# define CSIDL_COMMON_APPDATA 35 -# endif -# ifndef CSIDL_MYPICTURES -# define CSIDL_MYPICTURES 0x27 -# endif -# ifndef CSIDL_COMMON_DOCUMENTS -# define CSIDL_COMMON_DOCUMENTS 46 -# endif -# ifndef CSIDL_PROFILE -# define CSIDL_PROFILE 40 -# endif # include #endif diff --git a/gmodule/gmodule-win32.c b/gmodule/gmodule-win32.c index 1c7226a68..795dc0938 100644 --- a/gmodule/gmodule-win32.c +++ b/gmodule/gmodule-win32.c @@ -39,12 +39,6 @@ #include #endif -/* Default family is DESKTOP_APP which is DESKTOP | APP - * We want to know when we're only building for apps */ -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -#define G_WINAPI_ONLY_APP -#endif - static void set_error (const gchar *format, ...) @@ -133,8 +127,11 @@ find_in_any_module_using_toolhelp (const gchar *symbol_name) HANDLE snapshot; MODULEENTRY32 me32; - gpointer p; + gpointer p = NULL; + /* Under UWP, Module32Next and Module32First are not available since we're + * not allowed to search in the address space of arbitrary loaded DLLs */ +#if !defined(G_WINAPI_ONLY_APP) if ((snapshot = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE, 0)) == (HANDLE) -1) return NULL; @@ -149,6 +146,7 @@ find_in_any_module_using_toolhelp (const gchar *symbol_name) } CloseHandle (snapshot); +#endif return p; } diff --git a/meson.build b/meson.build index ed78359e5..d9e0a56ad 100644 --- a/meson.build +++ b/meson.build @@ -400,9 +400,22 @@ add_project_arguments(cc.get_supported_arguments(warning_c_args), language: 'c') # improve this. glib_link_flags = cc.get_supported_link_arguments(warning_c_link_args) -# Windows Support (7+) +# Windows SDK requirements and checks if host_system == 'windows' - glib_conf.set('_WIN32_WINNT', '0x0601') + # Check whether we're building for UWP apps + code = ''' + #include + #if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) + #error "Not building for UWP" + #endif''' + if cc.compiles(code, name : 'building for UWP') + glib_conf.set('G_WINAPI_ONLY_APP', true) + # We require Windows 10+ on WinRT + glib_conf.set('_WIN32_WINNT', '0x0A00') + else + # We require Windows 7+ on Win32 + glib_conf.set('_WIN32_WINNT', '0x0601') + endif endif functions = [