Skip to content

Commit 9a5b9b0

Browse files
committed
MB-41209: Use specific 'Winsock2.h' header for timeval (re-apply)
(Re-apply after previous revert due to missing some uses of Windows.h) When compiling under MSVC with 'WIN32_LEAN_AND_MEAN' defined (to avoid symbol collisions with glog / reduce number of unnecessary headers included), forestdb fails to compile with the following error: ..\forestdb\utils\gettimeofday_vs.cc(25): error C2027: use of undefined type 'timeval' forestdb\utils\gettimeofday_vs.h(17): note: see declaration of 'timeval' The issue is that gettimeofday_vs.h & time_utils.h includes Windows.h, which will only include the necessary header for 'timeval' (Winsock2.h) if WIN32_LEAN_AND_MEAN is not defined. Fix this by simply including the necessary Winsock2.h header directly. Change-Id: Icac0b7e476ff2a9fad2f4f9d4d998a06c29c49f4 Reviewed-on: http://review.couchbase.org/c/forestdb/+/135618 Tested-by: Build Bot <[email protected]> Reviewed-by: Trond Norbye <[email protected]>
1 parent cd4acaa commit 9a5b9b0

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@
375375

376376
#ifdef _MSC_VER
377377
// visual studio CL compiler
378-
#include <Windows.h>
378+
#include <Winsock2.h>
379379
#include "gettimeofday_vs.h"
380380
#define INLINE static inline
381381
//#define alloca(size) _alloca(size)

utils/gettimeofday_vs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define _JSAHN_GETTIMEOFDAY_VS
33

44
#include <time.h>
5-
#include <Windows.h>
5+
#include <Winsock2.h> // for timeval
66

77
#ifdef __cplusplus
88
extern "C" {

utils/time_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include <time.h>
2222
#if defined(WIN32) || defined(_WIN32)
23-
#include <Windows.h>
23+
#include <Winsock2.h> // for timeval
2424
#else
2525
#include <sys/time.h>
2626
#include <unistd.h>

0 commit comments

Comments
 (0)