baidu / sofa-pbrpc

A light-weight RPC implement of google protobuf RPC framework.
Other
2.13k stars 655 forks source link

mac下开启detail log编译不过 #124

Closed zd-double closed 7 years ago

zd-double commented 7 years ago

现象

mac下开启SOFA_PBRPC_ENABLE_DETAILED_LOGGING,导致编译不通过

原因

pthread_self()返回值pthread_t在linux平台定义为unsigned long int(/usr/include/bits/pthreadtypes.h), 但是在mac上定义为struct _opaque_pthread_t, BSD系列的系统上为其他结构体指针(如FreeBSD : pthread)因此不能采用static_cast转换。

解决方法

采用条件编译,判断在os x和BSD系列的平台上编译,采用reinterpret_cast的方式转换, linux平台仍然用static_cast转换。