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>
#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

View file

@ -12,14 +12,15 @@
std::optional<std::wstring> GetCurrentModulePath();
std::optional<std::wstring> 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

View file

@ -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);
}

View file

@ -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);
}