简体   繁体   中英

Dereferencing Pointer to incomplete type

I've been at this for a couple hours and can't figure out this probably stupid mistake. Here are the errors:

crawler.c:8: error: dereferencing pointer to incomplete type

crawler.c:9: error: dereferencing pointer to incomplete type

crawler.c:10: warning: return from incompatible pointer type

The code is:

//--------------------------Header File----------------------------------//
#ifndef CRAWLER_H 
#define CRAWLER_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "indexPage.h"
struct pointersWordControl{
    queryHelper **queryArray;
    char** URLs;
};
typedef struct pointersWordControl queryHelperExt;
queryHelperExt  *crawler(const char* FILE_NAME, const int MAX_N);
#endif  

//---------------------------------Crawler.c-------------------------------//
queryHelperExt *crawler(const char* FILE_NAME, const int Max_N)
{

    queryHelper **structArray = malloc(sizeof(struct wordControl*)*50); 
    char** urlString;
    urlString= missionControl(FILE_NAME, Max_N, structArray);
    struct queryHelperExt *queryPass=malloc(sizeof(struct pointersWordControl)*1);
    queryPass->queryArray=structArray;
    queryPass->URLs=urlString; 
    return queryPass;
}

Change

struct queryHelperExt *queryPass=malloc(sizeof(struct pointersWordControl)*1);

to

queryHelperExt *queryPass=malloc(sizeof(struct pointersWordControl)*1);

There is no struct queryHelperExt - the identifier queryHelperExt is a typedef for struct pointersWordControl and doesn't need the struct keywork.

Your problem is that you're declaring queryPass to be of type struct queryHelperExt which is different from the intended type of queryHelperExt . In C, adding the struct keyword makes it a different type (unlike C++).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM