Index: src/plugin/PluginDebug.cpp |
=================================================================== |
--- a/src/plugin/PluginDebug.cpp |
+++ b/src/plugin/PluginDebug.cpp |
@@ -20,6 +20,7 @@ |
#include "PluginClientBase.h" |
#include "PluginMutex.h" |
#include "PluginSettings.h" |
+#include <cstdint> |
class CPluginDebugLock : public CPluginMutex |
{ |
@@ -256,3 +257,29 @@ |
} |
#endif // ENABLE_DEBUG_RESULT_IGNORED |
+ |
+namespace |
+{ |
+ /* |
+ * To convert a pointer to a hexadecimal number, we need an integral type that has the same size as that of the pointer. |
+ */ |
+#if defined(_WIN64) |
+ typedef uint64_t voidIntegral; |
sergei
2015/12/21 11:14:28
What about using of `uintptr_t` but pay attention
Eric
2015/12/21 12:51:59
Already changed it once at your suggestion. We are
sergei
2015/12/21 13:04:47
According to http://en.cppreference.com/w/cpp/lang
Eric
2015/12/21 13:19:59
OK. Great. I didn't say it wouldn't work. I said i
sergei
2015/12/21 13:37:09
Less code less bugs, I think here it's proper plac
|
+ static_assert(sizeof(void*)==sizeof(voidIntegral),"WIN64: sizeof(long long) is not the same as sizeof(void*)"); |
sergei
2015/12/21 11:14:28
Here and below the message string is inconsistent
Eric
2015/12/21 12:51:59
Done.
|
+#elif defined(_WIN32) |
+ typedef uint32_t voidIntegral; |
+ static_assert(sizeof(void*)==sizeof(voidIntegral),"WIN32: sizeof(long) is not the same as sizeof(void*)"); |
+#else |
+#error Must compile with either _WIN32 or _WIN64 |
+#endif |
+} |
+ |
+std::wstring ToHexLiteral(void const* p) |
+{ |
+ std::wstringstream ss; |
+ ss << L"0x"; |
+ ss.width(sizeof(p) * 2); |
+ ss.fill(L'0'); |
+ ss << std::hex << reinterpret_cast<voidIntegral>(p); |
+ return ss.str(); |
+} |