Tyi*_*ilo 4 c++ objective-c reinterpret-cast automatic-ref-counting
我在启用ARC的Objective-C项目中包含了一个库的头文件.
我知道库没有启用ARC编译,但问题是库的头文件,特别是这些行:
template <typename Type_>
static inline Type_ &MSHookIvar(id self, const char *name) {
    Ivar ivar(class_getInstanceVariable(object_getClass(self), name));
    void *pointer(ivar == NULL ? NULL : reinterpret_cast<char *>(self) + ivar_getOffset(ivar));
    return *reinterpret_cast<Type_ *>(pointer);
}
我收到此错误:
Cast of an Objective-C pointer to 'char *' is disallowed with ARC
是否可以修复此错误?
整个头文件可以在这里找到:http://puu.sh/sTrH
您需要将初始化更改为pointer:
void *pointer(ivar == NULL ? NULL : reinterpret_cast<char *>((__bridge void *)self) + ivar_getOffset(ivar));
| 归档时间: | 
 | 
| 查看次数: | 1698 次 | 
| 最近记录: |