diff --git a/include/share/win_utf8_io.h b/include/share/win_utf8_io.h
index ba9ad75..353dd74 100644
--- a/include/share/win_utf8_io.h
+++ b/include/share/win_utf8_io.h
@@ -58,7 +58,10 @@ int chmod_utf8(const char *filename, int pmode);
 int utime_utf8(const char *filename, struct utimbuf *times);
 int unlink_utf8(const char *filename);
 int rename_utf8(const char *oldname, const char *newname);
+
+#ifdef FLAC__COMPAT_USE_WINAPI
 HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
+#endif
 
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/src/flac/decode.c b/src/flac/decode.c
index 3a6997b..a3c222c 100644
--- a/src/flac/decode.c
+++ b/src/flac/decode.c
@@ -25,10 +25,11 @@
 #include <math.h> /* for floor() */
 #include <stdio.h> /* for FILE etc. */
 #include <string.h> /* for strcmp(), strerror() */
+#define FLAC__COMPAT_USE_WINAPI /* for CreateFile_utf8 */
 #include "FLAC/all.h"
+#include "share/compat.h"
 #include "share/grabbag.h"
 #include "share/replaygain_synthesis.h"
-#include "share/compat.h"
 #include "decode.h"
 
 typedef struct {
diff --git a/src/share/grabbag/file.c b/src/share/grabbag/file.c
index 73f7fca..fb784b9 100644
--- a/src/share/grabbag/file.c
+++ b/src/share/grabbag/file.c
@@ -46,6 +46,7 @@
 #include <windows.h>
 #include <winbase.h>
 #endif
+#define FLAC__COMPAT_USE_WINAPI /* for CreateFile_utf8 */
 #include "share/grabbag.h"
 
 
diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c
index 6b5c56c..18a00da 100644
--- a/src/share/win_utf8_io/win_utf8_io.c
+++ b/src/share/win_utf8_io/win_utf8_io.c
@@ -40,6 +40,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
+#define FLAC__COMPAT_USE_WINAPI
 #include "share/win_utf8_io.h"
 
 #define UTF8_BUFFER_SIZE 32768
