vcpkg/ports/openal-soft/96f62e37e9ae015ee104e568cb57ea0d8964a84b.patch
2024-11-26 12:25:47 -08:00

90 lines
2.1 KiB
Diff

From 96f62e37e9ae015ee104e568cb57ea0d8964a84b Mon Sep 17 00:00:00 2001
From: Darryl Pogue <darryl@dpogue.ca>
Date: Sat, 23 Nov 2024 15:39:13 -0800
Subject: [PATCH] Only use noexcept in public headers on >= C++11
This resolves issues consuming openal-soft in projects that don't
explicitly specify a C++ standard of C++11 or newer.
This also handles the fact that __cplusplus is not set properly in MSVC
(always claiming to be 199711L) which prevented both the C++11 noexcept
and the C++17 noexcept annotations from taking effect.
Ref: https://github.com/kcat/openal-soft/pull/1071
---
include/AL/al.h | 14 +++++++++++++-
include/AL/alc.h | 14 +++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/include/AL/al.h b/include/AL/al.h
index e9f8f3b1..a4e3ad51 100644
--- a/include/AL/al.h
+++ b/include/AL/al.h
@@ -5,9 +5,19 @@
#ifdef __cplusplus
extern "C" {
+#ifdef _MSVC_LANG
+#define AL_CPLUSPLUS _MSVC_LANG
+#else
+#define AL_CPLUSPLUS __cplusplus
+#endif
+
#ifndef AL_DISABLE_NOEXCEPT
+#if AL_CPLUSPLUS >= 201103L
#define AL_API_NOEXCEPT noexcept
-#if __cplusplus >= 201703L
+#else
+#define AL_API_NOEXCEPT
+#endif
+#if AL_CPLUSPLUS >= 201703L
#define AL_API_NOEXCEPT17 noexcept
#else
#define AL_API_NOEXCEPT17
@@ -19,6 +29,8 @@ extern "C" {
#define AL_API_NOEXCEPT17
#endif
+#undef AL_CPLUSPLUS
+
#else /* __cplusplus */
#define AL_API_NOEXCEPT
diff --git a/include/AL/alc.h b/include/AL/alc.h
index 3311b57f..d048ca04 100644
--- a/include/AL/alc.h
+++ b/include/AL/alc.h
@@ -5,9 +5,19 @@
#ifdef __cplusplus
extern "C" {
+#ifdef _MSVC_LANG
+#define ALC_CPLUSPLUS _MSVC_LANG
+#else
+#define ALC_CPLUSPLUS __cplusplus
+#endif
+
#ifndef AL_DISABLE_NOEXCEPT
+#if ALC_CPLUSPLUS >= 201103L
#define ALC_API_NOEXCEPT noexcept
-#if __cplusplus >= 201703L
+#else
+#define ALC_API_NOEXCEPT
+#endif
+#if ALC_CPLUSPLUS >= 201703L
#define ALC_API_NOEXCEPT17 noexcept
#else
#define ALC_API_NOEXCEPT17
@@ -19,6 +29,8 @@ extern "C" {
#define ALC_API_NOEXCEPT17
#endif
+#undef ALC_CPLUSPLUS
+
#else /* __cplusplus */
#define ALC_API_NOEXCEPT
--
2.47.0