Hello all,
I'm building Kaldi on windows 7 using MSVS 2015, ran into a few problems, and here were my fixes
1. building 'kaldi-base' resulted in an macro redefinition error for 'snprintf'
#error Macro definition of snprintf conflicts with Standard Library function declaration
The offending code is in 'kaldi-utils.cc' on line 23
#elif defined(_WIN32) || defined(_MSC_VER) || defined(MINGW)
#include <Windows.h>
#define snprintf _snprintf
#else
Microsoft changed snprintf as of Windows 10 and MSVS 2015
https://msdn.microsoft.com/en-us/library/2ts7cx93.aspxAnd there is an explicit check for it in stdio.h with a little note
#define snprintf Do not define snprintf as a macro
I made a pull request to fix this (#499)
2. pthread.h was redefining the struct 'timespec'
'timespec': 'struct' type redefinition
The problem is pthread.h checks to see if 'timespec' is defined by looking at the wrong define for windows
#if !defined(_TIMESPEC_DEFINED)
#define _TIMESPEC_DEFINED
struct timespec {
time_t tv_sec;
long tv_nsec;
};
#endif /* _TIMESPEC_DEFINED */
Windows SDK uses _CRT_NO_TIME_T to determine if timespec should be defined, if it's not defined, it will define it.
Here is a patch for the file
--- pthread.h 2016-02-14 13:49:16.027430500 -0500
+++ pthread_new.h 2016-02-14 13:53:40.729116100 -0500
@@ -317,10 +317,12 @@
#define HAVE_STRUCT_TIMESPEC
#if !defined(_TIMESPEC_DEFINED)
#define _TIMESPEC_DEFINED
+#if defined(_MSC_VER) && _MSC_VER >= 1900 && defined(_CRT_NO_TIME_T)
struct timespec {
time_t tv_sec;
long tv_nsec;
};
+#endif /* _CRT_NO_TIME_T */
#endif /* _TIMESPEC_DEFINED */
#endif /* HAVE_STRUCT_TIMESPEC */