繁体   English   中英

C 中的未知类型名称?

[英]Unknown type name in C?

好的,所以我正在用 C 编写一些代码,该程序主要使用指针,我快完成了,但是有这个问题,我在代码的某些部分不断得到未知的类型名称。 例如,在下面的代码中,我不断收到“未知类型名称 Pulse”。本质上它使用 C 语言中的对象使用 tinytimber 内核,但代码中包含 Pulse。

#include "Pulse.h"
typedef struct {
       Object super;
       Pulse *PulserOne;
       Pulse *PulserTwo;
       Pulse *Pulsing;
} GUI;

这是创建脉冲的另一类代码。

typedef struct {
    Object super;
     int pin;   
     int frequency;
     int stored;
     int oldFrequency;
 } Pulse;
# define initPulse(pin, frequency,stored,oldFrequency{initObject(),number, frequency, stored, oldFrequency

这是声明对象的主类。

Pulse PulserOne = initPulse(4, 0, 0, 0, &p);
Pulse PulserTwo = initPulse(6, 0, 0, 0, &p);
GUI gui = initGUI(&PulserOne, &PulserTwo, &PulserOne);

我不断收到“未知类型名称脉冲”

使用之前移动Pulse的定义。 @UnholySheep

#include "Pulse.h"

// move here.
typedef struct {
    Object super;
    int pin;   
    int frequency;
    int stored;
    int oldFrequency;
 } Pulse;  // Pulse defined here

typedef struct {
    Object super;
    Pulse *PulserOne; // Pulse used here
    Pulse *PulserTwo;
    Pulse *Pulsing;
} GUI;

替代方案:声明Pulse的存在

//             v--v--------- Use some name        
typedef struct Fred Pulse;  // Pulse declared here

typedef struct   {
    Object super;
    Pulse *PulserOne; // Pulse used here
    Pulse *PulserTwo;
    Pulse *Pulsing;
} GUId;

typedef struct Fred {
    Object super;
    int pin;
    int frequency;
    int stored;
    int oldFrequency;
 } Pulse;  // Pulse defined here

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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