From b21066c89e336933e133091990f08453ed352c5d Mon Sep 17 00:00:00 2001 From: mjk Date: Fri, 5 Mar 2021 21:49:21 +0000 Subject: [PATCH] mark exception-safe C entry points as such --- .../api/include/shortcutcreator.h | 14 ++++++++------ .../api/include/win32.hpp | 19 ++++++++++--------- .../api/src/shortcutcreator.cpp | 2 +- .../windows-notification/api/src/win32.cpp | 4 ++-- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/plugins/windows-notification/api/include/shortcutcreator.h b/plugins/windows-notification/api/include/shortcutcreator.h index b9259f18..0fdcb078 100644 --- a/plugins/windows-notification/api/include/shortcutcreator.h +++ b/plugins/windows-notification/api/include/shortcutcreator.h @@ -3,12 +3,14 @@ #include #ifdef __cplusplus -extern "C" -{ +#define EXTERN extern "C" +#define NOEXCEPT noexcept +#else +#define EXTERN +#define NOEXCEPT #endif - gboolean TryCreateShortcut(const gchar* aumid); +EXTERN gboolean TryCreateShortcut(const gchar* aumid) NOEXCEPT; -#ifdef __cplusplus -} -#endif +#undef EXTERN +#undef NOEXCEPT diff --git a/plugins/windows-notification/api/include/win32.hpp b/plugins/windows-notification/api/include/win32.hpp index 1ee8872a..aa00121c 100644 --- a/plugins/windows-notification/api/include/win32.hpp +++ b/plugins/windows-notification/api/include/win32.hpp @@ -12,14 +12,15 @@ std::optional GetCurrentModulePath(); std::optional GetShortcutPath(); +#define EXTERN extern "C" +#define NOEXCEPT noexcept +#else +#define EXTERN +#define NOEXCEPT #endif -#ifdef __cplusplus -extern "C" -{ -#endif - gboolean SupportsModernNotifications(); - gboolean SetAppModelID(const gchar* aumid); -#ifdef __cplusplus -} -#endif +EXTERN gboolean SupportsModernNotifications() NOEXCEPT; +EXTERN gboolean SetAppModelID(const gchar* aumid) NOEXCEPT; + +#undef EXTERN +#undef NOEXCEPT diff --git a/plugins/windows-notification/api/src/shortcutcreator.cpp b/plugins/windows-notification/api/src/shortcutcreator.cpp index f6a91e78..49df2e3a 100644 --- a/plugins/windows-notification/api/src/shortcutcreator.cpp +++ b/plugins/windows-notification/api/src/shortcutcreator.cpp @@ -153,7 +153,7 @@ bool TryCreateShortcutInternal(const char *const aumid) extern "C" { - gboolean TryCreateShortcut(const gchar* aumid) + gboolean TryCreateShortcut(const gchar* aumid) noexcept { return g_try_invoke(TryCreateShortcutInternal, aumid); } diff --git a/plugins/windows-notification/api/src/win32.cpp b/plugins/windows-notification/api/src/win32.cpp index baa03d0f..57e99bb5 100644 --- a/plugins/windows-notification/api/src/win32.cpp +++ b/plugins/windows-notification/api/src/win32.cpp @@ -44,7 +44,7 @@ extern "C" // Not available in mingw headers, but linking works. NTSTATUS NTAPI RtlGetVersion(PRTL_OSVERSIONINFOW); - gboolean SupportsModernNotifications() + gboolean SupportsModernNotifications() noexcept { RTL_OSVERSIONINFOW rovi = { 0 }; rovi.dwOSVersionInfoSize = sizeof(rovi); @@ -55,7 +55,7 @@ extern "C" return FALSE; } - gboolean SetAppModelID(const gchar* aumid) + gboolean SetAppModelID(const gchar* aumid) noexcept { return g_try_invoke(SetAppModelIDInternal, aumid); }