gpt4 book ai didi

c - 结构体作为函数的输出

转载 作者:行者123 更新时间:2023-11-30 18:32:00 24 4
gpt4 key购买 nike

我编写了这段代码,但是当尝试编译它时,它返回了这个错误:

:24:8: error: conflicting types for ‘safe_syscall’
:19:10: note: previous implicit declaration of ‘safe_syscall’ was here

我指定了行数。

typedef struct syscall ditem;

void safe_syscall_set (vmi_instance_t vmi)
{
ditem *head,*tmp = NULL;
char *name;
int num;
FILE * fp;
fp = fopen ("syscall.list", "r");//file including syscall names and numbers in format "name number"
//read file of syscalls and numbers
while(fscanf(fp, "%s %d",name, &num)!= EOF);
{
tmp = head;
/* 19 */
head = safe_syscall(name,num,tmp,vmi);
}
return;
}

/* 24 */
ditem *safe_syscall (char *syscall,int num,ditem *head,vmi_instance_t vmi)
{
uint64_t *sys_call_table = 0xffffffff816003e0;
uint64_t *memory = (uint64_t *) malloc(sizeof(*sys_call_table));

char *path = "/home/ossl5/sysmap";//hardcoded
FILE *fp;
fp=fopen(path,"r");
if(!fp)
{
printf("ERROR CAN NOT OPEN SYSTEM.MAP FILE\n");
goto exit;
}
curr = (ditem *)malloc(sizeof(ditem));
curr->num = num;
curr->next = head;//new nodes are being added to head of the list
head = curr;
curr->sys_name = syscall;
//Calculating syscall handler size
curr->size = sys_routine_size(fp,syscall,num);
exit:
return head;
}

我猜结构作为输出有问题。这个结构是一个链接列表,每次调用safe_syscall函数时,新节点都会添加到列表的头部,并且新的头部由这个功能。

最佳答案

您尚未声明 safe_syscall(),因此假定返回 int。尝试在第一次调用之前添加声明 ditem *safe_syscall (char *syscall,int num,ditem *head,vmi_instance_t vmi);

关于c - 结构体作为函数的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17760433/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com