我有一个神秘的错误和一个警告。警告:整数在分配时初始化为指针,另一个是未找到符号,引用函数popdepholder。
我相信他们可能因某种存在的幻象功能而无论如何都会被关联但是无法看到或者其他什么
header dependency.h:
#include "relation.h"
#include "strhelp.h"
#include <time.h>
#ifndef _DEPENDENCY_H
#define _DEPENDENCY_H
typedef struct fd {
RELATION *left;
RELATION *right;
RELATION *referring; } DEPENDENCY;
typedef struct dh {
DEPENDENCY *data;
struct dh *next;
struct dh *prev; } DEP_HOLDER;
DEP_HOLDER * popdepholer(DEP_HOLDER **top);
...
void removedepholderat(DEP_HOLDER **list,int dest);
...
DEP_HOLDER * popdepholer(DEP_HOLDER **top) ###this function is not being seen
{
DEP_HOLDER * remove = 0;
if(*top)
{
remove=(*top);
if(remove->prev)
{
if(remove->next) /*the middle case*/
{
remove->prev->next=remove->next;
remove->next->prev=remove->prev;
(*top)=(*top)->next;
}
else /*the bottom case*/
{
remove->prev->next=0;
*top=0;
}
}
else if((remove->next)&&!(remove->prev)) /*the top case*/
{
remove->next->prev=0;
(*top)=(*top)->next;
}
else /*the single case*/
{
*top = 0;
}
remove->prev=0;
remove->next=0;
}
else
{
printf("In popdepholder, passed a null pointer!\n");
exit(4);
}
return remove;
}
...
void removedepholderat(DEP_HOLDER **list,int dest)
{
DEP_HOLDER *holder = *list;
if(dest == 1) #here
{
DEP_HOLDER * r = popdepholder(list); #here
destroydepholder(&r);
}
else
{
while((holder) && (dest>1))
{
holder=holder->next;
dest--;
}
if((holder) && dest==1)
{
DEP_HOLDER * r = popdepholder(&holder); #here
destroydepholder(&r);
}
}
}
#endif
main.c中:
#include "dependency.h"
DEP_HOLDER *mydp = getnewholder(d1);
...
DEP_HOLDER * a = popdepholder(&mydp);
错误:
In file included from test-dependency.c:3:
dependency.h: In function ‘removedepholderat’:
dependency.h:332: warning: initialization makes pointer from integer without a cast
dependency.h:344: warning: initialization makes pointer from integer without a cast
test-dependency.c: In function ‘main’:
test-dependency.c:37: warning: initialization makes pointer from integer without a cast
Undefined symbols for architecture x86_64:
"_popdepholder", referenced from:
_removedepholderat in ccUGYlgF.o
_main in ccUGYlgF.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
答案 0 :(得分:2)
您已声明并定义popdepholer
而不是popdepholder
(缺少第二个 d )。
答案 1 :(得分:0)
也许您正在尝试将32位库链接到64位二进制文件。检查你的makefile构建过程是否在正确的库中链接。