View Issue Details

IDProjectCategoryView StatusLast Update
0002699FSSCPBuild systempublic2012-08-21 10:19
ReporterEchelon9 Assigned ToEchelon9  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product Version3.6.14 
Target Version3.7.2Fixed in Version3.7.2 
Summary0002699: Replace deprecated hash_map on systems that support std::tr1::unordered_map
DescriptionAs reported by ni1s on IRC:

ni1s: phew, go_even_faster introduces quite the slew of new warnings on linux
[7:26pm] Echelon9: what are the most common one's?
[7:26pm] Echelon9: i.e. unused variables etc
[7:26pm] ni1s: the deprecated hash_map warning probably
[7:27pm] ni1s: /usr/lib/gcc/i686-pc-linux-gnu/4.6.3/include/g++-v4/backward/backward_warning.h:33:2: varning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
[7:29pm] Echelon9: what has hash_map been deprecated in favour of? something in Cx11?
[7:29pm] ni1s: std::tr1::unordered_map
[7:29pm] The_E: why would you deprecate hash_map at all?
[7:29pm] The_E: It's STL
[7:31pm] Echelon9: and if us utilise -Wno-deprecated to mask that warning, what is the next most common?
[7:31pm] Echelon9: (i'm trying to get a sense of materiality for the next most common additional warning)
[7:33pm] ni1s: patch for hash_map be here(with some refactoring) -> <see attached>
TagsNo tags attached.

Activities

Echelon9

2012-08-19 09:32

developer  

41012.patch (1,431 bytes)   
diff --git a/code/globalincs/vmallocator.h b/code/globalincs/vmallocator.h
index 659775f..3a957ed 100644
--- a/code/globalincs/vmallocator.h
+++ b/code/globalincs/vmallocator.h
@@ -9,11 +9,26 @@
 #include <string>
 #include <queue>
 
-#if defined __GNUC__ || defined __APPLE__
+#if defined __GNUC__
+#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+#if GCC_VERSION >= 40300
+#include <tr1/unordered_map>
+#define SCP_hash_map std::tr1::unordered_map
+#elif GCC_VERSION < 40300
 #include <ext/hash_map>
-#else
+#define SCP_hash_map std::hash_map
+#endif // GCC_VERSION
+#endif // __GNUC__
+
+#if defined __APPLE__ && ! defined __GNUC__
+#include <ext/hash_map>
+#define SCP_hash_map std::hash_map
+#endif // defined __APPLE__ && ! defined __GNUC__
+
+#if ! defined __APPLE__ && ! defined __GNUC__
 #include <hash_map>
-#endif
+#define SCP_hash_map stdext::hash_map
+#endif // ! defined __APPLE__ && ! defined __GNUC__
 
 #if defined(_MSC_VER) && _MSC_VER >= 1400 || !defined(_MSC_VER)
 
@@ -125,16 +140,7 @@ bool operator!=(const SCP_vm_allocator<T1>&, const SCP_vm_allocator<T2>&) throw(
 	return false;
 }
 
-#ifdef SCP_UNIX
-#define SCP_hash_map __gnu_cxx::hash_map
-#elif defined __APPLE__
-#define SCP_hash_map std::hash_map
 #else
-#define SCP_hash_map stdext::hash_map
-#endif
-
-#else
-
 #define SCP_string std::string
 #define SCP_stringstream std::stringstream
 #define SCP_map std::map
41012.patch (1,431 bytes)   

ni1s

2012-08-19 13:41

reporter  

hash_map.svn.patch (1,539 bytes)   
diff --git a/code/globalincs/vmallocator.h b/code/globalincs/vmallocator.h
index 659775f..5146b4d 100644
Index: code/globalincs/vmallocator.h
===================================================================
--- code/globalincs/vmallocator.h
+++ code/globalincs/vmallocator.h
@@ -9,11 +9,26 @@
 #include <string>
 #include <queue>
 
-#if defined __GNUC__ || defined __APPLE__
+#if defined __GNUC__
+#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+#if GCC_VERSION >= 40300
+#include <tr1/unordered_map>
+#define SCP_hash_map std::tr1::unordered_map
+#elif GCC_VERSION < 40300
 #include <ext/hash_map>
-#else
+#define SCP_hash_map __gnu_cxx::hash_map
+#endif // GCC_VERSION
+#endif // __GNUC__
+
+#if defined __APPLE__ && ! defined __GNUC__
+#include <ext/hash_map>
+#define SCP_hash_map std::hash_map
+#endif // defined __APPLE__ && ! defined __GNUC__
+
+#if ! defined __APPLE__ && ! defined __GNUC__
 #include <hash_map>
-#endif
+#define SCP_hash_map stdext::hash_map
+#endif // ! defined __APPLE__ && ! defined __GNUC__
 
 #if defined(_MSC_VER) && _MSC_VER >= 1400 || !defined(_MSC_VER)
 
@@ -125,16 +140,7 @@ bool operator!=(const SCP_vm_allocator<T1>&, const SCP_vm_allocator<T2>&) throw(
 	return false;
 }
 
-#ifdef SCP_UNIX
-#define SCP_hash_map __gnu_cxx::hash_map
-#elif defined __APPLE__
-#define SCP_hash_map std::hash_map
 #else
-#define SCP_hash_map stdext::hash_map
-#endif
-
-#else
-
 #define SCP_string std::string
 #define SCP_stringstream std::stringstream
 #define SCP_map std::map
hash_map.svn.patch (1,539 bytes)   

Echelon9

2012-08-19 14:11

developer   ~0013925

Committed in r9124, following code review on IRC with ni1s

niffiwan

2012-08-19 22:21

developer   ~0013926

I think there's a new compiler flag we need to add when using std::tr1::unordered_map, otherwise some versions of GCC won't compile (that's why I didn't suggest this change earlier). I'll investigate further and get back to you.

niffiwan

2012-08-21 10:19

developer   ~0013929

Sorry - got confused with the use of:

#include <unordered_map>
vrs
#include <tr1/unordered_map>

The first is the one that needs a compile flag (CXXFLAGS=-std=c++0x), the second does not.

Issue History

Date Modified Username Field Change
2012-08-19 09:31 Echelon9 New Issue
2012-08-19 09:31 Echelon9 Status new => assigned
2012-08-19 09:31 Echelon9 Assigned To => chief1983
2012-08-19 09:32 Echelon9 File Added: 41012.patch
2012-08-19 09:33 Echelon9 Status assigned => code review
2012-08-19 13:41 ni1s File Added: hash_map.svn.patch
2012-08-19 14:11 Echelon9 Note Added: 0013925
2012-08-19 14:11 Echelon9 Status code review => resolved
2012-08-19 14:11 Echelon9 Resolution open => fixed
2012-08-19 14:11 Echelon9 Assigned To chief1983 => Echelon9
2012-08-19 22:21 niffiwan Note Added: 0013926
2012-08-19 22:21 niffiwan Status resolved => feedback
2012-08-19 22:21 niffiwan Resolution fixed => reopened
2012-08-19 22:21 niffiwan Status feedback => code review
2012-08-21 10:19 niffiwan Note Added: 0013929
2012-08-21 10:19 niffiwan Status code review => resolved
2012-08-21 10:19 niffiwan Fixed in Version => 3.7.2
2012-08-21 10:19 niffiwan Resolution reopened => fixed