我正在尝试模拟我正在测试的源文件所包含的头文件。
报头以以下内容开头:
#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.发布于 2020-11-26 09:18:55
#error消息的输出意味着没有使用ICM_WHOAMI的任何(其他)定义。
为什么看不到#include之前的#define需要您未提供的其他信息
发布于 2020-11-26 21:20:01
我还遇到了没有传递到包含文件的定义的问题。尝试将define with选项-D直接传递给编译器和链接器,方法是将它们添加到project.yml:
:标志::测试::编译:- -D ICM42600 :链接:- -D ICM42600
https://stackoverflow.com/questions/65000008
复制相似问题