Datentyp von Header-File in Header-File einbinden

Gast #5393816
Lesenswert?

Hallo ich will den Datentyp aus Header 1 ic_t in eine zweites Header 2 
File includieren um Ihn in fan_t zu verwenden, dabei bekomme ich 
folgenden Fehler:

.\SRC\Control\FAN_CONTROL\fan_control.h(31): error:  #20: identifier 
"ic_t" is undefined

Meine google suche hat leider zu keinem Erfolg geführt, hat mir 
vielleicht jemand einen Tip wie es richtig geht?

//Header 1 -> input_capture.h
/* Define to prevent recursive inclusion 
-------------------------------------*/
#ifndef __input_capture_H
#define __input_capture_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include "stm32f4xx_hal.h"

typedef enum {
    IC_STATE_NO_INIT = 0,
    IC_STATE_OK,
    IC_STATE_ERROR
} ic_status_t;

typedef struct {
    ic_status_t status;
    uint16_t   rpm;
    uint16_t   timer;
    TIM_HandleTypeDef   hICtim;
    TIM_HandleTypeDef *p_channel;
    uint32_t   icChannel;
    uint16_t  lastICVal;
    uint16_t  actualSteps;
    uint16_t  targetSteps;
  uint16_t    lastCntVal;
  uint16_t    cntSteps;
} ic_t;

/* declaration of function prototypes 
-----------------------------------------*/
void ic_fan_start(ic_t* pThis);
uint16_t ic_get_fan_rpm (ic_t *pThis);
uint32_t ic_calc_prescaler(uint32_t freq);
void ic_fan_init(ic_t *pThis, uint32_t tim_cnt_mode);
void fan_input_capture_isr(ic_t * pThis);

#ifdef __cplusplus
}
#endif

#endif /* __input_capture_H */

//Header 2 -> -> fan_control.h
/* Define to prevent recursive inclusion 
-------------------------------------*/
#ifndef __fan_control_H
#define __fan_control_H

#ifdef __cplusplus
extern "C" {
#endif


#include "stdint.h"
#include "input_capture.h"
#include "pwm.h"

typedef enum {
    FAN_STATE_IDLE = 0,
    FAN_STATE_ON,
    FAN_STATE_ERROR,
} fan_state_t;

typedef struct {
    fan_state_t state;
    ic_t tacho;
    pwm_t   pwm;
    uint16_t timer;
    float esum;
} fan_t;

/* Private typedef 
-----------------------------------------------------------*/
void set_ic_fan1(fan_t* pThis);
fan_state_t fan_run (fan_t *pThis);

uint16_t fan_getActualRPM (fan_t *pThis);
void fan_pi_controller (fan_t *pThis);
fan_state_t fan_run (fan_t * pThis);

#ifdef __cplusplus
}
#endif

#endif /* __fan_control_H */
Gast #5394124
Lesenswert?

Denn Header sieht er oder zumindest bekomme ich da keinen Fehle, ich 
habe eine Ordner Struktur in Bezug auf die jeweiligen Layer und Module 
angelegt und den Pfad anschliessend (Keils uVison 5) für alle Files 
eingebunden (siehe Bild).
Angehängte Dateien:
(Firma: Torrox.de) #5394134
Lesenswert?

Ich würde mal tippen, dass der Fehler in dem Teil des Codes liegt, den 
Du uns nicht zeigst. Typischerweise treten solche Fehler auf, wenn zwei 
header sich gegenseitig includieren. Kann es ein, dass Du mehrere 
Versionen der Datei auf der Platte hast (/old /back /copy)?

Edit: Lass Dir mal den Präprozessor-Output vom Compiler generieren und 
durchsuche den, nach dem fehlenden Typen.

BTW: Bezeichner, die zwei Unterstriche enthalten gehören dem Compiler 
und sollten nicht von Dir verwendet werden.

mfg Torsten

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren