Eclipse CDT 索引器无法解析 ae_f32 类型

Eclipse CDT indexer cannot resolve ae_f32 type

在尝试将浮点 C 代码移植到定点代码时,我在 Eclipse 中遇到了一个问题 CDT - 索引器无法识别我用来替换的 f32 类型标准 C float。代码编译和构建良好(使用 MinGW GCC 编译器)。它是 C 和 C++ 代码的混合体。

在 Eclipse 中看到数百条警告很烦人:Type f32 could not be resolved。这是在第 3 方 DSP 库代码中定义类型的方式:

#define B_(X) b_##X
... 
#define f32 B_(f32) 
... 
/* type declarations */

#define DECLARE_TYPE(s) \
    namespace s##_space { \
    class s##_; \
    } \
    typedef s##_space::s##_ s;
... 
DECLARE_TYPE(f32);
...
namespace f32_space 
{
    //etc...

为什么无法识别 f32 类型?

已解决。

问题是 .c 文件中混合了 C 和 C++。我有 .c 扩展名的源代码,其中包含 ifdefed C++ 代码 (#if defined(__cplusplus) 等),并且编译器也设置为 C++。然而,索引器将这些文件解析为 C。当我生成索引器日志文件(Project\C C++ Index\Create 解析器日志文件)时,我注意到以下内容:Language: GNU C.

然后我添加了语言映射:

Settings\C C++ General\Language Mappings

  • C Header file 映射到 C++
  • C Source file 映射到 C++

一旦我改变了它,它就起作用了。