开发者

How to print ACE_thread_t using printf()

开发者 https://www.devze.com 2022-12-12 03:12 出处:网络
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 metho

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]);
0

精彩评论

暂无评论...
验证码 换一张
取 消