错误:对类型为'const ItemInstance'的引用无法绑定到类型为'void'的右值
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误:对类型为'const ItemInstance'的引用无法绑定到类型为'void'的右值相关的知识,希望对你有一定的参考价值。
我试图在ios版本的MinecraftPE中添加食谱,但出现此错误。我该怎么办?
错误:对类型'const ItemInstance'的引用无法绑定到类型'void'的右值..._ inst-> iteminstance(_inst,Item :: mItems [432],0),“ ###”,“#S#”,“ ###”,d ...注意:此处将参数传递给参数“ inst”void Recipes :: addShapedRecipe(Recipes * res,const ItemInstance&inst,co ...
源代码在这里:
Tweak.xm
#import "../substrate.h"
#import <UIKit/UIKit.h>
#import <mach-o/dyld.h>
#import <initializer_list>
#import <vector>
#import <map>
#import <mach-o/dyld.h>
#import <string>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <initializer_list>
#import <vector>
#import <mach-o/dyld.h>
#import <UIKit/UIKit.h>
#import <iostream>
#import <stdio.h>
#include <sstream>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <string.h>
#include <algorithm>
#include <fstream>
#include <ifaddrs.h>
#include <stdint.h>
#include <dlfcn.h>
#include "Item.h"
#include "ItemInstance.h"
#include "Recipes.h"
ItemInstance* _inst = NULL;
void (*ItemInstance::iteminstance_)(ItemInstance*, Item const*, int);
void ItemInstance::iteminstance(ItemInstance* inst, Item const* item, int meta) {
_inst = inst;
iteminstance_(inst, item, meta);
}
void (*Recipes::addShapedRecipe_)(Recipes* res, const ItemInstance& inst, const std::string& s1, const std::string& s2, const std::string& s3, const std::vector<Recipes::Type, std::allocator<Recipes::Type>>& ress);
void Recipes::addShapedRecipe(Recipes* res, const ItemInstance& inst, const std::string& s1, const std::string& s2, const std::string& s3, const std::vector<Recipes::Type, std::allocator<Recipes::Type>>& ress) {
addShapedRecipe_(res, inst, s1, s2, s3, ress);
}
void (*Recipes::_init_)(Recipes* res);
void Recipes::_init(Recipes* res) {
Recipes::_init_(res);
const std::vector<Recipes::Type, std::allocator<Recipes::Type>>& def = definition<Item*, Item*>('#', Item::mItems[296], 'S', Item::mItems[368]);
res->addShapedRecipe(res, _inst->iteminstance(_inst, Item::mItems[432], 0), "###", "#S#", "###", def);
}
%ctor {
MSHookFunction((void*)(0x1007569a4 + _dyld_get_image_vmaddr_slide(0)), (void*)&ItemInstance::iteminstance, (void**)&ItemInstance::iteminstance_);
MSHookFunction((void*)(0x100781d74 + _dyld_get_image_vmaddr_slide(0)), (void*)&Recipes::addShapedRecipe, (void**)&Recipes::addShapedRecipe_);
MSHookFunction((void*)(0x100774f40 + _dyld_get_image_vmaddr_slide(0)), (void*)&Recipes::_init, (void**)&Recipes::_init_);
MSHookFunction((void*)(0x1012ae238 + _dyld_get_image_vmaddr_slide(0)), (void*)&Item::mItems, NULL);
}
Recipes.h
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <stdint.h>
#include "ItemInstance.h"
class Recipes {
public:
class Type {
public:
Item* item;
uintptr_t* block;
ItemInstance inst;
char c;
};
public:
static void (*_init_)(Recipes* res);
static void _init(Recipes* res);
static void (*addShapedRecipe_)(Recipes* res, const ItemInstance& inst, const std::string& s1, const std::string& s2, const std::string& s3, const std::vector<Recipes::Type, std::allocator<Recipes::Type>>& ress);
static void addShapedRecipe(Recipes* res, const ItemInstance& inst, const std::string& s1, const std::string& s2, const std::string& s3, const std::vector<Recipes::Type, std::allocator<Recipes::Type>>& ress);
};
ItemInstance.h
#pragma once
#include <memory>
#include "Item.h"
class ItemInstance {
public:
static void (*iteminstance_)(ItemInstance*, Item const*, int);
static void iteminstance(ItemInstance* inst, Item const* item, int meta);
};
Item.h
#pragma once
#include <string>
#include <memory>
#include <vector>
#include <unordered_map>
class Item {
public:
char filler[200];
public:
static Item* mItems[512];
};
要解决编译错误,您需要传递*_inst
,而不是_inst->iteminstance(_inst, Item::mItems[432], 0)
。
这无助您确保在调用_inst
之前已填充Recipes::_init
。
大概您的ItemInstance
定义与您的钩子正在拦截的定义不匹配,因此您的Recipes::Type
的定义也不匹配。找到正确定义的位置。
以上是关于错误:对类型为'const ItemInstance'的引用无法绑定到类型为'void'的右值的主要内容,如果未能解决你的问题,请参考以下文章
错误 C2440: 'initializing' : 不能从'const mynamespace::mytype*'转换为'const T*'。(示例代
'number'类型的参数不能分配给array.includes()中'never'类型的参数
返回对字符串对象的引用,错误:“const string&”类型的引用初始化无效。 C++