gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 04:26:57 26 4
gpt4 key购买 nike

我想了解 C 语言编译器的错误。

在文件 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;

然后我在另一个文件 temperature.c 中创建变量:

ButterwothSecondOrderFilterParameter_str TMP_TemperatureLowPassFilterParameter_STR;

然后我在 temperature.h 中将这个新变量声明为 extern,以便在另一个文件中使用它:

extern ButterwothSecondOrderFilterParameter_str TMP_TemperatureLowPassFilterParameter_STR;

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

例如 temperature.c 只包含 temperature.h 并访问 application.h 的 typedef 结构,我将 application.h 包含在 temperature.h 中。

对于我的 *.h 文件,我总是用 :

#ifndef xxxx
#define xxxx
#endif

这是最后一个产生错误的声明:

Description Resource    Path    Location    Type
unknown type name 'ButterwothSecondOrderFilterParameter_str'

我不知道我的错误在哪里......?

最佳答案

只是我将 application.h 包含在 temperature.h 中。那么temperature.h是temperature.c中唯一包含的文件。我补充说 temperature.h 包含在 application.h 中也很正常,没有任何后果。

我试图直接在temperature.c中添加application.h,但我有同样的错误。

我试图删除 temperature.h 中的外部声明,它起作用了。

所以 temperature.h 的类型未知,但 temperature.c 的类型未知....我不明白。

关于c - typedef struct 和 extern 声明的未知类型名称错误 - C 语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40502759/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com