Skip to content

Commit

Permalink
Fix build with MinGW v6.0.0
Browse files Browse the repository at this point in the history
Including pthread.h is a workaround for a bug in the MinGW headers,
where pthread.h (which defines _POSIX_THREAD_SAFE_FUNCTIONS)
has to be included before time.h so that time.h defines
localtime_r correctly, wich depends in _POSIX_THREAD_SAFE_FUNCTIONS
being defined previously.

Compilation error:
[...]srt_compat.h:78:9: error: 'localtime_r' was not declared in this scope
  • Loading branch information
ylatuya authored and rndi committed Jan 7, 2019
1 parent 2ef4ef0 commit 170663f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions common/win/wintime.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

#include <winsock2.h>
#include <windows.h>
// HACK: This include is a workaround for a bug in the MinGW headers
// where pthread.h, which defines _POSIX_THREAD_SAFE_FUNCTIONS,
// has to be included before time.h so that time.h defines
// localtime_r correctly
#include <pthread.h>
#include <time.h>

#ifdef __cplusplus
Expand Down

0 comments on commit 170663f

Please sign in to comment.