[flac-dev] [PATCH 5/5] win_utf8_io: Avoid forbidden functions when building for WinRT/UWP

Hugo Beauzée-Luyssen hugo at beauzee.fr
Fri Jan 6 12:53:39 UTC 2017


---
 src/share/win_utf8_io/win_utf8_io.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c
index c61d27f3..1437b41e 100644
--- a/src/share/win_utf8_io/win_utf8_io.c
+++ b/src/share/win_utf8_io/win_utf8_io.c
@@ -34,6 +34,7 @@
 #endif
 
 #include <windows.h>
+#include <winapifamily.h>
 #include "share/win_utf8_io.h"
 #include "share/windows_unicode_filenames.h"
 
@@ -164,11 +165,13 @@ size_t strlen_utf8(const char *str)
 int win_get_console_width(void)
 {
 	int width = 80;
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
 	CONSOLE_SCREEN_BUFFER_INFO csbi;
 	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
 	if(hOut != INVALID_HANDLE_VALUE && hOut != NULL)
 		if (GetConsoleScreenBufferInfo(hOut, &csbi) != 0)
 			width = csbi.dwSize.X;
+#endif
 	return width;
 }
 
@@ -176,6 +179,7 @@ int win_get_console_width(void)
 
 static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
 {
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
 	DWORD out;
 	int ret;
 
@@ -202,6 +206,11 @@ static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
 	if (ret < 0)
 		return ret;
 	return len;
+#else
+    (void)stream;
+    OutputDebugStringW(text);
+    return len;
+#endif
 }
 
 int printf_utf8(const char *format, ...)
-- 
2.11.0



More information about the flac-dev mailing list