LLVM Create a PointerValue from c-side-ptr

// Llvm doesn't let you create a PointerValue from a c-side ptr.  Instead
// cast it to an int and then to 'type'.

Value* CastPtrToLlvmPtr(Type* type, const void* ptr) {  
         Constant* const_int = ConstantInt::get(Type::getInt64Ty(context()), (int64_t)ptr);  
          return ConstantExpr::getIntToPtr(const_int, type);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章