简体   繁体   English

typedef struct和extern声明的未知类型名称错误 - C语言

[英]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. 我想了解我的编译器在C语言中的错误。

In a file application.h, I create a typedef struct : 在文件application.h中,我创建了一个typedef结构:

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 : 然后我在另一个文件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 : 然后我将此新变量声明为temperature.h中的extern,以便在另一个文件中使用它:

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 对于* .c文件,我只包含他的相关* .h文件,如果我需要来自另一个* .h文件的全局变量,我将它包含在* .h文件中

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. 例如,temperature.c只包含temperature.h和访问application.h的typedef结构。我在temperature.h中包含application.h。

For my *.h file I always encapsulate with a : 对于我的* .h文件,我总是用以下内容封装:

#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. 我在temperature.h中包含了application.h。 Then temperature.h is the only file included in temperature.c. 那么temperature.h是temperature.c中包含的唯一文件。 I add that temperature.h is included in application.h too normally without consequence. 我补充说,temperature.h通常包含在application.h中而没有后果。

I tried to add application.h directly in temperature.c but I have the same error. 我试着直接在temperature.c中添加application.h但是我有同样的错误。

I tried to delete the extern declaration in temperature.h and it works. 我试图删除temperature.h中的extern声明,它可以工作。

So the type in unknown for temperature.h but not for temperature.c....I don't understand. 所以温度类型未知,但温度不是....我不明白。

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

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