diff options
Diffstat (limited to 'absl/time')
-rw-r--r-- | absl/time/clock_benchmark.cc | 2 | ||||
-rw-r--r-- | absl/time/duration.cc | 4 | ||||
-rw-r--r-- | absl/time/duration_test.cc | 4 | ||||
-rw-r--r-- | absl/time/internal/cctz/src/time_zone_format.cc | 10 | ||||
-rw-r--r-- | absl/time/time.cc | 4 | ||||
-rw-r--r-- | absl/time/time.h | 9 | ||||
-rw-r--r-- | absl/time/time_test.cc | 4 |
7 files changed, 36 insertions, 1 deletions
diff --git a/absl/time/clock_benchmark.cc b/absl/time/clock_benchmark.cc index a69fe00ba263..c5c795ecbd23 100644 --- a/absl/time/clock_benchmark.cc +++ b/absl/time/clock_benchmark.cc @@ -15,6 +15,8 @@ #if !defined(_WIN32) #include <sys/time.h> +#else +#include <winsock2.h> #endif // _WIN32 #include <cstdio> diff --git a/absl/time/duration.cc b/absl/time/duration.cc index 67791feedfb5..a3ac61a91894 100644 --- a/absl/time/duration.cc +++ b/absl/time/duration.cc @@ -49,6 +49,10 @@ // // Arithmetic overflows/underflows to +/- infinity and saturates. +#if defined(_MSC_VER) +#include <winsock2.h> // for timeval +#endif + #include <algorithm> #include <cassert> #include <cctype> diff --git a/absl/time/duration_test.cc b/absl/time/duration_test.cc index e3cede6ee9d4..5dce9ac8a557 100644 --- a/absl/time/duration_test.cc +++ b/absl/time/duration_test.cc @@ -12,6 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if defined(_MSC_VER) +#include <winsock2.h> // for timeval +#endif + #include <chrono> // NOLINT(build/c++11) #include <cmath> #include <cstdint> diff --git a/absl/time/internal/cctz/src/time_zone_format.cc b/absl/time/internal/cctz/src/time_zone_format.cc index 25850980b541..aa8898750dc8 100644 --- a/absl/time/internal/cctz/src/time_zone_format.cc +++ b/absl/time/internal/cctz/src/time_zone_format.cc @@ -18,8 +18,18 @@ # endif #endif +#if defined(HAS_STRPTIME) && HAS_STRPTIME +# if !defined(_XOPEN_SOURCE) +# define _XOPEN_SOURCE // Definedness suffices for strptime. +# endif +#endif + #include "absl/time/internal/cctz/include/cctz/time_zone.h" +// Include time.h directly since, by C++ standards, ctime doesn't have to +// declare strptime. +#include <time.h> + #include <cctype> #include <chrono> #include <cstddef> diff --git a/absl/time/time.cc b/absl/time/time.cc index 977a95173db1..338c4523d1b1 100644 --- a/absl/time/time.cc +++ b/absl/time/time.cc @@ -33,6 +33,10 @@ #include "absl/time/time.h" +#if defined(_MSC_VER) +#include <winsock2.h> // for timeval +#endif + #include <cstring> #include <ctime> #include <limits> diff --git a/absl/time/time.h b/absl/time/time.h index 594396c751df..0534780516d0 100644 --- a/absl/time/time.h +++ b/absl/time/time.h @@ -65,7 +65,14 @@ #if !defined(_MSC_VER) #include <sys/time.h> #else -#include <winsock2.h> +// We don't include `winsock2.h` because it drags in `windows.h` and friends, +// and they define conflicting macros like OPAQUE, ERROR, and more. This has the +// potential to break Abseil users. +// +// Instead we only forward declare `timeval` and require Windows users include +// `winsock2.h` themselves. This is both inconsistent and troublesome, but so is +// including 'windows.h' so we are picking the lesser of two evils here. +struct timeval; #endif #include <chrono> // NOLINT(build/c++11) #include <cmath> diff --git a/absl/time/time_test.cc b/absl/time/time_test.cc index 4d791f4d11aa..e2b2f8097021 100644 --- a/absl/time/time_test.cc +++ b/absl/time/time_test.cc @@ -14,6 +14,10 @@ #include "absl/time/time.h" +#if defined(_MSC_VER) +#include <winsock2.h> // for timeval +#endif + #include <chrono> // NOLINT(build/c++11) #include <cstring> #include <ctime> |