简体   繁体   中英

unknown type name error with typedef struct and extern declaration - C language

I would like to understand an error from my compiler in C language.

In a file application.h, I create a typedef struct :

typedef struct
{
    FLOAT64 CoefficientA1_F64;
    FLOAT64 CoefficientA2_F64;
    FLOAT64 CoefficientB0_F64;
    FLOAT64 CoefficientB1_F64;
    FLOAT64 CoefficientB2_F64;
    FLOAT32 OldOldRawValue_F32;
    FLOAT32 OldRawValue_F32;
    FLOAT32 RawValue_F32;
    FLOAT32 OldOldFilteredValue_F32;
    FLOAT32 OldFilteredValue_F32;
    FLOAT32 FilteredValue_F32;
}ButterwothSecondOrderFilterParameter_str;

Then I create variable in another file temperature.c :

ButterwothSecondOrderFilterParameter_str TMP_TemperatureLowPassFilterParameter_STR;

Then I declare this new variable as extern in temperature.h to do the possibility to use it in another file :

extern ButterwothSecondOrderFilterParameter_str TMP_TemperatureLowPassFilterParameter_STR;

For a *.c file I only includes his related *.h file and if I need global variable from another *.h file I include it in the *.h file

For example temperature.c only includes temperature.h and to access to the typedef struct of application.h I include application.h in temperature.h.

For my *.h file I always encapsulate with a :

#ifndef xxxx
#define xxxx
#endif

And this is this last declaration which generates an error :

Description Resource    Path    Location    Type
unknown type name 'ButterwothSecondOrderFilterParameter_str'

I don't know where's my error.... ?

Justly I included application.h in temperature.h. Then temperature.h is the only file included in temperature.c. I add that temperature.h is included in application.h too normally without consequence.

I tried to add application.h directly in temperature.c but I have the same error.

I tried to delete the extern declaration in temperature.h and it works.

So the type in unknown for temperature.h but not for temperature.c....I don't understand.

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