c - 从一个 header 结构到另一个 header 中的结构体

标签 c header struct

我在这方面遇到了麻烦... 我有这个标题:

#ifndef PESSOA_H
#define PESSOA_H

typedef struct pa{
    int idade;
    int atend;
}pessoa;


void inicPessoa(pessoa *ps, int id);

#endif

并且,在 filaC.h 中:

#ifndef FILAC_H
#define FILAC_H

#include "pessoa.h"

typedef struct pessoa elem_t;

typedef struct no{
  elem_t info;
  struct no *prox, *ant;
} No;

typedef No * Fila;
#endif

但是编译器说 filaC.h 上的 fiel 信息类型不完整。

elem_t info;更改为struct elem_t into;没有效果。

最佳答案

您没有名为 struct pessoa 的类型。您有struct pa,还有pessoa(类型定义)。

所以你需要改变这个:

typedef struct pessoa elem_t;

进入以下之一:

typedef struct pa elem_t;
typedef pessoa elem_t;

关于c - 从一个 header 结构到另一个 header 中的结构体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24420738/

相关文章:

c - inptr 和 outptr 是什么意思

pointers - Golang 结构的指针或无指针引用其他结构及其原因

ios - 创建结构的空数组给我一个错误

C - 结构指针

c - 用C获取文件的扩展名

c - 为什么 64 位 Ubuntu 中的 8 字节数组 (C) 占用 16 字节?

nginx - 强制 nginx 写一个空的/空白的 http 授权请求 header

c++ - 共享 header 导致多重定义符号错误

c++ - 命名空间内类的循环依赖问题

c - 如何修复: initialization from incompatible pointer type