ref: d8826b0dbbb783d951ca4155cec2bf5c22038672
parent: 6bc1cdd62c79c27c771421dbbf7b8fe19d733a42
parent: 3b16ff8b7f3fcefd80e31ff057312b3b811197c8
author: Kevin Lenzo <66268906+lenzo-duo@users.noreply.github.com>
date: Fri Aug 14 14:47:32 EDT 2020
Merge pull request #15 from kubo/mingw32 Fix Mingw32 compilation
--- a/configure
+++ b/configure
@@ -4080,11 +4080,17 @@
# For the Windows under mingw32 environment
# http://www.mingw.org
shared=false
- CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32 -shared"
- MINGWPREF="i386-mingw32-"
- CC="${MINGWPREF}gcc"
- RANLIB="${MINGWPREF}ranlib"
- AR="${MINGWPREF}ar"
+ CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32"
+ PREFLEN=`expr match "$CC" ".*-gcc"`
+ if expr $PREFLEN != 0 > /dev/null; then
+ # When $CC includes "-gcc", use the preceding
+ # charactors + '-' as MINGPREF.
+ # for example:
+ # CC=x86_64-w64-mingw32-gcc.exe
+ # --> MINGWPREF=x86_64-w64-mingw32-
+ PREFLEN=`expr $PREFLEN - 3`
+ MINGPREF=`expr substr $CC 1 $PREFLEN`
+ fi
WINDRES="${MINGWPREF}windres"
DLLTOOL="${MINGWPREF}dlltool"
DLLWRAP="${MINGWPREF}dllwrap"
@@ -4355,7 +4361,8 @@
fi
-ac_fn_c_check_header_mongrel "$LINENO" "mmsystem.h" "ac_cv_header_mmsystem_h" "$ac_includes_default"
+ac_fn_c_check_header_compile "$LINENO" "mmsystem.h" "ac_cv_header_mmsystem_h" "#include <windows.h>
+"
if test "x$ac_cv_header_mmsystem_h" = xyes; then :
AUDIODRIVER="wince"
AUDIODEFS=-DCST_AUDIO_WINCE
@@ -4368,11 +4375,6 @@
wince*)
AUDIODRIVER="wince"
AUDIODEFS=-DCST_AUDIO_WINCE
- AUDIOLIBS=
- ;;
- mingw*)
- AUDIODRIVER="none"
- AUDIODEFS=-DCST_AUDIO_NONE
AUDIOLIBS=
;;
android*)
--- a/configure.in
+++ b/configure.in
@@ -136,11 +136,17 @@
# For the Windows under mingw32 environment
# http://www.mingw.org
shared=false
- CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32 -shared"
- MINGWPREF="i386-mingw32-"
- CC="${MINGWPREF}gcc"
- RANLIB="${MINGWPREF}ranlib"
- AR="${MINGWPREF}ar"
+ CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32"
+ PREFLEN=`expr match "$CC" ".*-gcc"`
+ if expr $PREFLEN != 0 > /dev/null; then
+ # When $CC includes "-gcc", use the preceding
+ # charactors + '-' as MINGPREF.
+ # for example:
+ # CC=x86_64-w64-mingw32-gcc.exe
+ # --> MINGWPREF=x86_64-w64-mingw32-
+ PREFLEN=`expr $PREFLEN - 3`
+ MINGPREF=`expr substr $CC 1 $PREFLEN`
+ fi
WINDRES="${MINGWPREF}windres"
DLLTOOL="${MINGWPREF}dlltool"
DLLWRAP="${MINGWPREF}dllwrap"
@@ -387,7 +393,9 @@
AC_CHECK_HEADER(mmsystem.h,
[AUDIODRIVER="wince"
AUDIODEFS=-DCST_AUDIO_WINCE
- AUDIOLIBS=-lwinmm])
+ AUDIOLIBS=-lwinmm],
+ [],
+ [#include <windows.h>])
dnl I don't care what you ask for, for wince you get wince
case "$target_os" in
@@ -394,11 +402,6 @@
wince*)
AUDIODRIVER="wince"
AUDIODEFS=-DCST_AUDIO_WINCE
- AUDIOLIBS=
- ;;
- mingw*)
- AUDIODRIVER="none"
- AUDIODEFS=-DCST_AUDIO_NONE
AUDIOLIBS=
;;
android*)
--- a/include/cst_file.h
+++ b/include/cst_file.h
@@ -101,7 +101,13 @@
#ifdef _WIN32
#define snprintf c99_snprintf
-__inline int c99_vsnprintf(char* str, size_t size, const char* format,
+#ifdef __GNUC__
+#define INLINE static inline
+#else
+#define INLINE __inline
+#endif
+
+INLINE int c99_vsnprintf(char* str, size_t size, const char* format,
va_list ap) {
int count = -1;
if (size != 0)
@@ -110,7 +116,7 @@
count = _vscprintf(format, ap);
return count;
}
-__inline int c99_snprintf(char* str, size_t size, const char* format, ...)
+INLINE int c99_snprintf(char* str, size_t size, const char* format, ...)
{
int count;
va_list ap;
--- a/include/cst_tokenstream.h
+++ b/include/cst_tokenstream.h
@@ -130,7 +130,7 @@
int (*getc)(cst_tokenstream *ts));
void ts_close(cst_tokenstream *ts);
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__GNUC__)
__inline int ts_utf8_sequence_length(char c0);
#else
int ts_utf8_sequence_length(char c0);
--- a/src/audio/au_wince.c
+++ b/src/audio/au_wince.c
@@ -43,6 +43,10 @@
#include "cst_audio.h"
#include "cst_alloc.h"
+#ifndef MAXULONG_PTR
+#define DWORD_PTR DWORD
+#endif
+
typedef struct au_wince_pdata_struct {
HWAVEOUT wo;
HANDLE bevt;
@@ -84,7 +88,7 @@
}
static void CALLBACK sndbuf_done(HWAVEOUT drvr, UINT msg,
- DWORD udata, DWORD param1, DWORD param2)
+ DWORD_PTR udata, DWORD_PTR param1, DWORD_PTR param2)
{
WAVEHDR *hdr = (WAVEHDR *)param1;
cst_audiodev *ad = (cst_audiodev *)udata;
@@ -137,7 +141,7 @@
wfx.nBlockAlign = wfx.nChannels*wfx.wBitsPerSample/8;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec*wfx.nBlockAlign;
err = waveOutOpen(&wo,WAVE_MAPPER,&wfx,
- (DWORD)sndbuf_done,(DWORD)ad,
+ (DWORD_PTR)sndbuf_done,(DWORD_PTR)ad,
CALLBACK_FUNCTION);
if (err != MMSYSERR_NOERROR)
{
--- a/src/utils/cst_tokenstream.c
+++ b/src/utils/cst_tokenstream.c
@@ -266,7 +266,7 @@
(*buffer)[p] = '\0';
}
- #ifdef _WIN32
+ #if defined _WIN32 && !defined(__GNUC__)
__inline int ts_utf8_sequence_length(char c0)
#else
int ts_utf8_sequence_length(char c0)
--- a/windows/Makefile
+++ b/windows/Makefile
@@ -40,7 +40,7 @@
## Also an example command line program ##
## ##
## At top level ##
-## ./configure --target=i386-mingw32 ##
+## ./configure ##
## make ##
## ##
###########################################################################