|
我编辑C程序时,有个函数递归调用,代码如下:
void dirwalk(char *dirname){
char filename[256];
DIR *dirp;
struct dirent *direntp;
struct stat st;
if((dirp = opendir(dirname)) == NULL){
printf("Could not open directory: %s \n",dirname);
exit(1);
}
while((direntp = readdir(dirp)) != NULL){
strcpy(filename,dirname);
if(filename[strlen(filename)-1] != '/')
strcat(filename,"/");
if((strcmp(direntp -> d_name,".") != 0)&& (strcmp(direntp -> d_name,"..") != 0)){
strcat(filename,direntp -> d_name);
if(stat(filename,&st) == -1){
printf("error:stat \n");
exit(1);
}
if((st.st_mode&S_IFMT) == S_IFDIR)
{dirwalk(filename);}
else
printf("%s\n",filename);
}
}
closedir(dirp);
}
在linux下用GCC编译通不过,显示
/tmp/cyC7Js.o(.eh_frame+0x11): undefined reference to '__gxx_personality_v0'
collect2:ld return 1 exit status
我用的是redhat 9.0,请问这是为什么?如何修改? |
|