首页 > 解决方案 > Ceedling未能模拟标题

问题描述

我正在尝试模拟我正在测试的源文件中包含的标头。

标头以以下内容开头:

#if defined(ICM42600)
#define ICM_WHOAMI ICM42600_WHOAMI
#elif defined(ICM42602)
#define ICM_WHOAMI ICM42602_WHOAMI
#elif defined(ICM42605)
#define ICM_WHOAMI ICM42605_WHOAMI
#elif defined(ICM42622)
#define ICM_WHOAMI ICM42622_WHOAMI
#elif defined(ICM42686)
#define ICM_WHOAMI ICM42686_WHOAMI
#elif defined(ICM42688)
#define ICM_WHOAMI ICM42688_WHOAMI
#elif defined(ICM42608)
#define ICM_WHOAMI ICM42608_WHOAMI
#elif defined(IIM42623)
#define ICM_WHOAMI IIM42623_WHOAMI
#elif defined(IIM42624)
#define ICM_WHOAMI IIM42624_WHOAMI
#elif defined(IIM42625)
#define ICM_WHOAMI IIM42625_WHOAMI
#elif defined(ICM40608)
#define ICM_WHOAMI ICM40608_WHOAMI
#else
#error "Please define which ICM variant is targeted. Possible values: ICM42600, ICM42602, ICM42605, ICM42686, ICM42688, ICM42622, ICM42608, ICM4068"
#endif

我试图像这样模拟它:

#define ICM42600 1
#include "mock_Icm426xxDefs.h"

但是,在尝试运行 ceedling 测试时,我不断收到以下错误:

----------------------------
Generating include list for Icm426xxDefs.h...
build/temp/_Icm426xxDefs.h:74:2: error: #error "Please define which ICM variant is targeted. Possible values: ICM42600, ICM42602, ICM42605, ICM42686, ICM42688, ICM42622, ICM42608, ICM4068"
 #error "Please define which ICM variant is targeted. Possible values: ICM42600, ICM42602, ICM42605, ICM42686, ICM42688, ICM42622, ICM42608, ICM4068"
  ^~~~~```

I have no idea how to deal with this. I was under the impression that ceedling would automatically mock headers, and there's no error saying what I can do to resolve this.

标签: ccmockceedling

解决方案


消息的输出#error意味着没有使用任何(其他)定义ICM_WHOAMI

为什么未看到#define之前#include需要您未提供的其他信息


推荐阅读