Converting LPTHREAD_START_ROUTINE to int
I'm working with a C++ code base which contains some lines 开发者_JAVA百科like the following:
CreateThread(NULL, 0, MyThreadMethod, NULL, 0, NULL);
I would like to write the value of MyThreadMethod
to debug output. (I suppose it's a hexadecimal address).
MyThreadMethod
has the type LPTHREAD_START_ROUTINE
. I already have a method called OutputDebugInt
which can write an int
to debug output. When I to compile the line
OutputDebugInt(MyThreadMethod);
then the compiler issues the error
cannot convert parameter 1 from
unsigned long (__stdcall *)(void *)
toint
.
So is there a way to convert LPTHREAD_START_ROUTINE
to int
(or something else which can be written to debug output)?
std::basic_ostringstream<TCHAR> ss;
ss << static_cast<void*>(&MyThreadMethod);
::OutputDebugString(ss.str().c_str());
Converting to int
is possible on 32-bit platforms, but not 64-bit platforms, so I'd stick with creating a string instead.
精彩评论