mark exception-safe C entry points as such

This commit is contained in:
mjk 2021-03-05 21:49:21 +00:00 committed by LAGonauta
parent 1bd1376cea
commit b21066c89e
4 changed files with 21 additions and 18 deletions

View file

@ -3,12 +3,14 @@
#include <glib.h> #include <glib.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" #define EXTERN extern "C"
{ #define NOEXCEPT noexcept
#else
#define EXTERN
#define NOEXCEPT
#endif #endif
gboolean TryCreateShortcut(const gchar* aumid); EXTERN gboolean TryCreateShortcut(const gchar* aumid) NOEXCEPT;
#ifdef __cplusplus #undef EXTERN
} #undef NOEXCEPT
#endif

View file

@ -12,14 +12,15 @@
std::optional<std::wstring> GetCurrentModulePath(); std::optional<std::wstring> GetCurrentModulePath();
std::optional<std::wstring> GetShortcutPath(); std::optional<std::wstring> GetShortcutPath();
#define EXTERN extern "C"
#define NOEXCEPT noexcept
#else
#define EXTERN
#define NOEXCEPT
#endif #endif
#ifdef __cplusplus EXTERN gboolean SupportsModernNotifications() NOEXCEPT;
extern "C" EXTERN gboolean SetAppModelID(const gchar* aumid) NOEXCEPT;
{
#endif #undef EXTERN
gboolean SupportsModernNotifications(); #undef NOEXCEPT
gboolean SetAppModelID(const gchar* aumid);
#ifdef __cplusplus
}
#endif

View file

@ -153,7 +153,7 @@ bool TryCreateShortcutInternal(const char *const aumid)
extern "C" extern "C"
{ {
gboolean TryCreateShortcut(const gchar* aumid) gboolean TryCreateShortcut(const gchar* aumid) noexcept
{ {
return g_try_invoke(TryCreateShortcutInternal, aumid); return g_try_invoke(TryCreateShortcutInternal, aumid);
} }

View file

@ -44,7 +44,7 @@ extern "C"
// Not available in mingw headers, but linking works. // Not available in mingw headers, but linking works.
NTSTATUS NTAPI RtlGetVersion(PRTL_OSVERSIONINFOW); NTSTATUS NTAPI RtlGetVersion(PRTL_OSVERSIONINFOW);
gboolean SupportsModernNotifications() gboolean SupportsModernNotifications() noexcept
{ {
RTL_OSVERSIONINFOW rovi = { 0 }; RTL_OSVERSIONINFOW rovi = { 0 };
rovi.dwOSVersionInfoSize = sizeof(rovi); rovi.dwOSVersionInfoSize = sizeof(rovi);
@ -55,7 +55,7 @@ extern "C"
return FALSE; return FALSE;
} }
gboolean SetAppModelID(const gchar* aumid) gboolean SetAppModelID(const gchar* aumid) noexcept
{ {
return g_try_invoke(SetAppModelIDInternal, aumid); return g_try_invoke(SetAppModelIDInternal, aumid);
} }