C 取消引用指向不完整类型抽象数据类型的指针

C 取消引用指向不完整类型抽象数据类型的指针,c,pointers,abstract-data-type,C,Pointers,Abstract Data Type,我有以下代码部分: 字典.h #ifndef _DICTIONARY_H #define _DICTIONARY_H typedef struct _dict_t dict_t; typedef dict_t *Dictionary; Dictionary dict_new(void); (...) 字典.c #include "dictionary.h" struct _dict_t { unsigned int size; char **data; }; Dictio

我有以下代码部分:

字典.h

#ifndef _DICTIONARY_H
#define _DICTIONARY_H

typedef struct _dict_t dict_t;
typedef dict_t *Dictionary;

Dictionary dict_new(void);
(...)
字典.c

#include "dictionary.h"
struct _dict_t {
    unsigned int size;
    char **data;
};

Dictionary dict_new(void){
    Dictionary dict = NULL;
    dict = calloc(1, sizeof(struct _dict_t));
    dict->data = calloc(1, sizeof(char));
    dict->size = 0;
    return (dict);
}
#include "dictionary.h"
Dictionary main_dict; // global dictionary
Dictionary ignored;   // Yes, i know its horrible

int is_known(char *word){
    int i;
    for (i = 0; i < main_dict->size; ++i)  {
        if (strcmp(main_dict->data[i], word) == 0)
            return 1;
    }

    for (i = 0; i < ignored->size; ++i){
        if (strcmp(ignored->data[i], word) == 0)
            return 1;
    }
    return 0;
}

int main(){
    (...)
}
main.c

#include "dictionary.h"
struct _dict_t {
    unsigned int size;
    char **data;
};

Dictionary dict_new(void){
    Dictionary dict = NULL;
    dict = calloc(1, sizeof(struct _dict_t));
    dict->data = calloc(1, sizeof(char));
    dict->size = 0;
    return (dict);
}
#include "dictionary.h"
Dictionary main_dict; // global dictionary
Dictionary ignored;   // Yes, i know its horrible

int is_known(char *word){
    int i;
    for (i = 0; i < main_dict->size; ++i)  {
        if (strcmp(main_dict->data[i], word) == 0)
            return 1;
    }

    for (i = 0; i < ignored->size; ++i){
        if (strcmp(ignored->data[i], word) == 0)
            return 1;
    }
    return 0;
}

int main(){
    (...)
}

我找不到错误。发生了什么?

当类型不完整时,编译器不知道该类型的实例中有什么。您需要提供类型的定义,然后才能取消引用它。

您正在取消引用指向不完整类型的指针。哪个词或表达不清楚?你用谷歌搜索过吗?
typedef
一个简单的指针不是一个好主意,因为实现缺少
*
,否则代码很难被理解。