Arrays 取消引用指向不完整结构类型的指针

Arrays 取消引用指向不完整结构类型的指针,arrays,c,dynamic,Arrays,C,Dynamic,我有一个struct,我试图将偏移量存储到我的mp3length中,并将从文件读取的数据存储到我的数据中。但是,当我将偏移量分配给动态数组时,它会告诉我“取消对不完整类型“struct mp3data_t”的引用指针”。有人能够解释这个错误吗 我的错误在mp3[num]->mp3length=mp3filesize; typedef struct mp3 { char *data; int mp3length; } mp3data_t; void listFilesRecur

我有一个struct,我试图将偏移量存储到我的mp3length中,并将从文件读取的数据存储到我的数据中。但是,当我将偏移量分配给动态数组时,它会告诉我“取消对不完整类型“struct mp3data_t”的引用指针”。有人能够解释这个错误吗

我的错误在
mp3[num]->mp3length=mp3filesize;

typedef struct mp3 {
    char *data;
    int mp3length;
} mp3data_t; 

void listFilesRecursively(char *basePath)
{
    char path[1000];
    int file_length;
    DIR *current = opendir(basePath);
    // Unable to open directory stream
    if (!current)
            return;

        while ((entry = readdir(current)) != NULL)
        {
            if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0)
        {
             printf("%s\n", entry->d_name);

            // Construct new path from our base path
                strcpy(path, basePath);
                strcat(path, "/");
                strcat(path, entry->d_name);
            
                printf("Path: %s\n", path);
            
                file_length = strlen(entry->d_name);
                if(entry->d_name[file_length - 1] == 51 &&
                  entry->d_name[file_length - 2] == 112 &&
                  entry->d_name[file_length - 3] == 109)    
                {
                    printf("------------------\n");
                    printf("Writing %s to file\n", entry->d_name);
                    printf("------------------\n");         
                    if(length < (num + 1))
                    {
                        length = num + 1;
                    }
                    FILE *mp3file;
                    if ((mp3file = fopen(path, "rb")) != NULL)
                    {
                        //SET POINTER TO THE END OF THE FILE TO GET THE SIZE
                        fseek(mp3file, 0, SEEK_END);
                        int mp3filesize = ftell(mp3file);
                        // SET POINTER BACK TO THE BEGINNING
                        fseek(mp3file, 0, SEEK_SET);
                        
                        mp3 = realloc(mp3, sizeof(mp3data_t*) * length);
                        mp3[num] = malloc(mp3filesize + 1);
                        
                        mp3[num]->mp3length = mp3filesize;
                        
                        int ret = fread(mp3[num]->data, sizeof(char), mp3filesize, mp3file);
                        if(ret == 0)
                        {
                            printf("nothing read\n");
                        }
                        fclose(mp3file);
                    }
                    else
                    {
                        printf("ERROR READING FILE\n");
                    }
                    // THEN USE FSEEK 
                    
                    //strcpy(data[num], entry->d_name);
           
                    num++;
                }
                listFilesRecursively(path);
            }
        }
    closedir(current);
    return;
}
typedef结构mp3{
字符*数据;
int mp3length;
}MP3数据;
递归作废列表文件(char*basePath)
{
字符路径[1000];
int文件长度;
DIR*current=opendir(基本路径);
//无法打开目录流
如果(!当前)
返回;
while((entry=readdir(当前))!=NULL)
{
如果(strcmp(条目->数据单元名称“.”)=0和&strcmp(条目->数据单元名称“…”)!=0)
{
printf(“%s\n”,条目->数据单元名称);
//从基本路径构造新路径
strcpy(路径、基本路径);
strcat(路径“/”;
strcat(路径、条目->数据单元名称);
printf(“路径:%s\n”,路径);
文件长度=strlen(条目->文件名);
如果(条目->文件名[文件长度-1]==51&&
条目->文件名[文件长度-2]==112&&
条目->文件名[文件长度-3]==109)
{
printf(“------------------------\n”);
printf(“将%s写入文件\n”,条目->数据单元名称);
printf(“------------------------\n”);
如果(长度<(数值+1))
{
长度=num+1;
}
文件*mp3file;
if((mp3file=fopen(路径,“rb”)!=NULL)
{
//设置指向文件末尾的指针以获取大小
fseek(mp3file,0,SEEK_END);
int mp3filesize=ftell(mp3file);
//将指针设置回起始位置
fseek(mp3file,0,SEEK_SET);
mp3=realloc(mp3,sizeof(mp3data\u t*)*长度);
mp3[num]=malloc(mp3filesize+1);
mp3[num]->mp3length=mp3filesize;
int-ret=fread(mp3[num]->data,sizeof(char),mp3filesize,mp3file);
如果(ret==0)
{
printf(“未读\n”);
}
fclose(mp3file);
}
其他的
{
printf(“读取文件时出错”);
}
//然后使用FSEEK
//strcpy(数据[num],条目->数据单元名称);
num++;
}
列表文件递归(路径);
}
}
closedir(当前);
返回;
}

您在此处声明的是
struct mp3
mp3data\u t
struct mp3data\u t
未声明(或至少未在此处发布)

看起来您应该使用
struct mp3
mp3data\u t
中的一种