简体   繁体   中英

Unknown type name in C?

Ok, so I am programming some code in C the program is mainly using pointers I am almost done but have this issue with I keep getting unknown type name on parts of the code. For example in the code below I keep getting ''Unknown type name Pulse'' Essentially it uses objects in C using the tinytimber kernel but Pulse is included in the code.

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

This is another class of the code where pulse is created.

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

This is the main class where the objects are declared.

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

I keep getting ''Unknown type name Pulse''

Move the definition of Pulse before its use. @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;

Alternative: Declare the existence of 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

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