Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法调试Eclipse linux中的代码错误找不到源malloc.c_C_Linux_Eclipse_Ubuntu_Malloc - Fatal编程技术网

无法调试Eclipse linux中的代码错误找不到源malloc.c

无法调试Eclipse linux中的代码错误找不到源malloc.c,c,linux,eclipse,ubuntu,malloc,C,Linux,Eclipse,Ubuntu,Malloc,我正在ubuntu上使用EclipseIDE 我已经编写了创建树头的简单代码。 代码正在成功编译。但在调试时,当它执行malloc语句时会出现错误 错误 在“/build/buildd/glibc-2.19/malloc/malloc.c”中找不到源文件 找到文件或编辑源查找路径以包含其位置 /* * tree.c * * Created on: 04-Dec-2014 * Author: etron */ #include<stdio.h> #in

我正在ubuntu上使用EclipseIDE 我已经编写了创建树头的简单代码。 代码正在成功编译。但在调试时,当它执行malloc语句时会出现错误

错误

在“/build/buildd/glibc-2.19/malloc/malloc.c”中找不到源文件 找到文件或编辑源查找路径以包含其位置

    /*
 * tree.c

 *
 *  Created on: 04-Dec-2014
 *      Author: etron
 */

#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
struct node
{
    int key_value;
    struct node *right;
    struct node *left;
};
struct node *root=0;

struct node* insert(int key,struct node **leaf)
{
    if(*leaf == 0)
    {
        *leaf = (struct node*) malloc(sizeof(struct node));
        (*leaf)->key_value = key;
        (*leaf)->left = 0;
        (*leaf)->right = 0;
        return 0;
    }
}


void  main()
{
    struct node *bt=0;
    int i=100;


    insert(i,&bt);

}
/*
*树
*
*创建日期:2014年12月4日
*作者:etron
*/
#包括
#包括
#包括
结构节点
{
int key_值;
结构节点*右;
结构节点*左;
};
结构节点*root=0;
结构节点*插入(int键,结构节点**叶)
{
如果(*leaf==0)
{
*叶=(结构节点*)malloc(sizeof(结构节点));
(*leaf)->key_值=key;
(*叶)->左=0;
(*叶)->右=0;
返回0;
}
}
void main()
{
结构节点*bt=0;
int i=100;
插入(i和bt);
}

在malloc中调试几乎没有什么好处。只是不要试图进入马洛克。你的主要观点是错误的<代码>int main(无效)。不要强制转换malloc的返回值。启用并注意编译器警告。它会抱怨您没有从insert返回
malloc
stdlib.h
声明。为什么要包括
malloc.h
? –大卫·赫弗南

谢谢你,先生,它的工作与步骤超过运行
–user1551103

如果删除
malloc
头文件,编译器是否显示任何错误消息?在malloc中调试几乎没有什么好处。只是不要试图进入马洛克。你的主要观点是错误的<代码>int main(无效)。不要强制转换malloc的返回值。启用并注意编译器警告。它会抱怨您没有从insert返回
malloc
stdlib.h
声明。为什么要包含
malloc.h
?在我看来,如果你不想让调试器呕吐,你应该去掉你的glibc,或者让源文件可用。我已经尝试过了,但没有出现同样的错误。int main不做任何更改,也尝试了不强制转换malloc的类型,但当到达malloc()语句时,在执行单步执行时仍然出现错误。@DavidHeffernan谢谢您,先生它与单步执行一起工作