How to print ACE_thread_t using printf()
ACE_OS::thr_self() returns ACE_thread_t. ACE logger has a switch "\t" to print it. How can I do it if I want to print 开发者_StackOverflowthread id by using printf()?
If ACE doesn't provide a method to do it you have to figure out its type. Given that it is ACE, it is probably hidden behind 3 typedefs nested in 5 #defines. The header file OS_NS_Thread.h
looks like as good a starting point as any.
ACE? C++? Why not use iostream instead of printf?
ACE_thread_t id = ACE_OS::thr_self();
unsigned char content[sizeof(id)];
size_t i;
memcpy(content, &id, sizeof(id) );
for (i=0; i<sizeof(id); ++i) printf("%02X",content[i]);
精彩评论