Я как-то испортил , включая , но не смог найти ошибку:
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef DEBUG
#define DLOG(x) printf(x)
#define PLOG(x,y) printf(x,y)
#else
#define DLOG(x)
#define PLOG(x,y)
#endif
harddrive::Results* harddrive::search_for(char* start,char* target,char** ignore,int size) {
PLOG("work directory: %s",start);
DIR* curr_dir = opendir(start);
Results* local = new Results;
if(!curr_dir) {
printf(" opendir() failure, probably no real directory: %s",start);
errno = 0;
return NULL;
}
struct dirent* elem;
while( (elem = readdir(curr_dir)) ) {
//form URI
char* uri = form_uri(start,curr_dir->d_name); //here is the actual error
struct stat st;
lstat(elem->d_name,&st);
if( S_ISDIR(st.st_mode) ) {
if( !do_ignore(uri,ignore,size) )
local = merge(local,search_for( form_uri(start,elem->d_name), target,ignore,size));
}
else if( S_ISREG(st.st_mode) ) { //this is line 41
Выход компилятора:
Directory.cpp: In function ‘harddrive::Results* harddrive::search_for(char*, char*, char**, int)’:
Directory.cpp:34:38: error: invalid use of incomplete type ‘struct DIR’
/usr/include/dirent.h:128:16: error: forward declaration of ‘struct DIR’
€: я прошу прощения за неудобства, но я вставил старый код ошибки, прежде чем я начал переключаться между строками, но теперь это правильно.