Skip to content

Commit 9ab7c73

Browse files
matthauckxfxyjwf
authored andcommitted
Fix missing std::tr1::hash on GCC 4.1 (#2907)
Rather than crashing on use (doh!) better to just declare this platform is missing a proper hash_map/hash_set implementation and use the std::map/std::set emulation. Fixes regression introduced by #1913
1 parent 126082c commit 9ab7c73

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • src/google/protobuf/stubs

src/google/protobuf/stubs/hash.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040

4141
#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1
4242
#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
43-
#define GOOGLE_PROTOBUF_HAVE_64BIT_HASH 1
4443

4544
// Use C++11 unordered_{map|set} if available.
4645
#if ((_LIBCPP_STD_VER >= 11) || \
@@ -93,8 +92,11 @@
9392
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
9493
# endif
9594

95+
// GCC <= 4.1 does not define std::tr1::hash for `long long int` or `long long unsigned int`
9696
# if __GNUC__ == 4 && __GNUC__MINOR__ <= 1
97-
# undef GOOGLE_PROTOBUF_HAVE_64BIT_HASH
97+
# define GOOGLE_PROTOBUF_MISSING_HASH
98+
# include <map>
99+
# include <set>
98100
# endif
99101

100102
// Version checks for MSC.

0 commit comments

Comments
 (0)