baidu / sofa-pbrpc

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

fix the unit_test compile error #163

Closed demiaowu closed 7 years ago

demiaowu commented 7 years ago

fix the Issue #150 .

While using the parameter -Dprivate=public of g++ in the unit_test module, it result in the confict with the header file of sstream in the gcc 6.2.0 . Much more detail information can be get at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65899. I copy a new sstream file for the unit_test module only. For the sstream, I just add the private: to explicit declare the member struct __xfer_bufptrs to make it consistency while using -Dprivate=public for unit test. Note that you must copy the sstream file in your cpp's include directory to cover the ./sofa-pbrpc/unit_test/sstream/sstream, then find the declare of the memberstruct __xfer_bufptrs, if it is implicitly private when it's declared, you must explicitly declare it as private. Accordingly, the build guide of unit_test in the wiki should be modified.

Thanks.

zd-double commented 7 years ago

@demiaowu Thanks for your pull request, but it seems failed to compile on other versions compiler.

demiaowu commented 7 years ago

@zd-double 编译错误是预期;还需要将当前安装sofa-pbrpc的机器下的C++ sstream头文件覆盖 sofa-pbrpc/unit_test/sstream/sstream,然后将struct __xfer_bufptrs修改为显示的声明private。因为考虑到不同版本的gcc,不一定会存在这个问题(新版本会有这个问题),上述修改过程很难用脚本实现,所以只能手动修改,不然就会触发编译错误。而且参考:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65899 ,gcc官方好像没有意愿修复这个问题——But I'm not interested in supporting -Dprivate=public, it's just wrong.,所以建议了此解决方案,但需要在wiki unit_test 构建指南中指出。Thanks~

cyshi commented 7 years ago

我理解在单测的Makefile中直接用 -fno-access-control 替换 -Dprivate=public 就可以了

demiaowu commented 7 years ago

@cyshi 对,我刚开始想当然了(以为只是编译器忽略了访问权限检查,但运行期会报错),修正了重新提了。参见 #164 @zd-double 。Thanks~