aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-03 12:55:02 -0700
committerChris Robinson <[email protected]>2018-11-03 12:55:02 -0700
commite9d17c51912bbec566279290a435e504ace7aa0c (patch)
treee1950cd8a047158777acaa6b3f8b59f1c7d2d403
parent5482efc9214d180e1f67fc528f593098ad20a678 (diff)
Move wstr_to_utf8 to compat.h
-rw-r--r--Alc/backends/wasapi.cpp16
-rw-r--r--Alc/compat.h23
2 files changed, 23 insertions, 16 deletions
diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp
index 2dc44c87..f2adf328 100644
--- a/Alc/backends/wasapi.cpp
+++ b/Alc/backends/wasapi.cpp
@@ -136,22 +136,6 @@ std::vector<DevMap> PlaybackDevices;
std::vector<DevMap> CaptureDevices;
-std::string wstr_to_utf8(const WCHAR *wstr)
-{
- std::string ret;
-
- int len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
- if(len > 0)
- {
- ret.resize(len);
- WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &ret[0], len, nullptr, nullptr);
- ret.pop_back();
- }
-
- return ret;
-}
-
-
HANDLE ThreadHdl;
DWORD ThreadID;
diff --git a/Alc/compat.h b/Alc/compat.h
index e0f6cbd9..c478c01d 100644
--- a/Alc/compat.h
+++ b/Alc/compat.h
@@ -19,6 +19,29 @@ FILE *al_fopen(const char *fname, const char *mode);
#define HAVE_DYNLOAD 1
+#ifdef __cplusplus
+} // extern "C"
+
+#include <string>
+
+inline std::string wstr_to_utf8(const WCHAR *wstr)
+{
+ std::string ret;
+
+ int len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
+ if(len > 0)
+ {
+ ret.resize(len);
+ WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &ret[0], len, nullptr, nullptr);
+ ret.pop_back();
+ }
+
+ return ret;
+}
+
+extern "C" {
+#endif /* __cplusplus */
+
#else
#define al_fopen fopen