[英]Ceedling failing to mock header
I am trying to mock a header which is included by a source file I am testing.我正在尝试模拟我正在测试的源文件中包含的 header。
The header begins with the following: header 开头如下:
#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
and I am attempting to mock it like so:我试图像这样模拟它:
#define ICM42600 1
#include "mock_Icm426xxDefs.h"
However, I keep getting the following error when trying to run ceedling tests:但是,在尝试运行 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.
The output of the #error
message means that none of the (other) definitions of ICM_WHOAMI
was used. #error
消息的 output 意味着没有使用ICM_WHOAMI
的(其他)定义。
Why the #define
before the #include
was not seen would require other info that you have not provided为什么看不到
#include
之前的#define
需要您未提供的其他信息
I had also problems with defines that were not passed to included files.我也遇到了未传递给包含文件的定义的问题。 Try to pass the define with option -D directly to the compiler and linker by adding them to the project.yml:
尝试通过将选项 -D 的定义直接传递给编译器和 linker,方法是将它们添加到 project.yml:
:flags: :test: :compile: : : - -D ICM42600:link: : : - -D ICM42600 :标志::测试::编译:::--D ICM42600:链接:::--D ICM42600
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.