Bug #19125 2013-09-19 07:17
mojca
std::tr1 should not be used in c++11
Please see:
http://cplusplusmusings.wordpress.com/2013/06/03/whats-up-with-tr1-and-c11-and-libc/
and the MacPorts ticket:
https://trac.macports.org/ticket/40515
When using c++11 the compilation may fail with
../../src/include/prep.h:409:10: fatal error: 'tr1/memory' file not found
#include <tr1/memory>
See the link above for explanation about the possible solutions.
- Category
- Group
- Platform:All
- Status
- Closed
- Close date
- 2013-10-02 17:04
- Assigned to
History
Basically, I think C::B support old GCC, so in case you are using a modern GCC with c++11 option enabled, those old tr1 headers should be put in some preprocessor branches.
I didn't understand the reply. But what about the following patch?
--- src/include/prep.h.orig
+++ src/include/prep.h
@@ -406,14 +406,24 @@ template<typename whatever> inline ID GetID()
inline ID GetID() { return GetID<void>(); }
inline ID ConstructID(unsigned int i) { return ID(i); }
+#if __cplusplus >= 201103L
+#include <memory>
+#else
#include <tr1/memory>
+#endif
// Add std::shared_ptr in a namespace, so different implementations can be used with different compilers
namespace cb
{
+#if __cplusplus >= 201103L
+ using std::shared_ptr;
+ using std::static_pointer_cast;
+ using std::weak_ptr;
+#else
using std::tr1::shared_ptr;
using std::tr1::static_pointer_cast;
using std::tr1::weak_ptr;
+#endif
}
#if defined(__APPLE__) && defined(__MACH__)
Other Apple developers said this wasn't enough, so the revised patch seems to be:
--- src/include/prep.h (revision 9374)
+++ src/include/prep.h (working copy)
@@ -406,14 +406,27 @@
inline ID GetID() { return GetID<void>(); }
inline ID ConstructID(wxIntPtr i) { return ID(i); }
+// Just included to possibly set _LIBCPP_VERSION
+#include <ciso646>
+
+#if __cplusplus >= 201103L || defined(_LIBCPP_VERSION)
+#include <memory>
+#else
#include <tr1/memory>
+#endif
// Add std::shared_ptr in a namespace, so different implementations can be used with different compilers
namespace cb
{
+#if __cplusplus >= 201103L || defined(_LIBCPP_VERSION)
+ using std::shared_ptr;
+ using std::static_pointer_cast;
+ using std::weak_ptr;
+#else
using std::tr1::shared_ptr;
using std::tr1::static_pointer_cast;
using std::tr1::weak_ptr;
+#endif
}
#if defined(__APPLE__) && defined(__MACH__)
This may be closed as fixed (r9377). Thank you.
This bug is now fixed in HEAD.
Thank you for reporting it.