小编DHe*_*hot的帖子

如何在 Arduino 上比较 __FlashStringHelper* 和 char*?

我有一个将文本行输出到串行的板。我需要将这些文本行与我所知道的文本进行比较。本质上,我想做strcmp(thestring,F("knownstring")),但是似乎没有一个采用 FlashStringHelper* 类型的 strcmp 版本。有 strcmp_P 使用const PROGMEM char *,但这似乎完全是不同的事情。我在 Arduino 论坛帖子上看到有人建议通过使用 遍历 flash-string 来编写一个函数progmem_read_byte (b, i),但该函数实际上并不存在,并且最接近的等效项 ( pgm_read_byte(b+i)) 似乎不适用于 FlashStringHelper* - 我收到类似error: invalid use of incomplete type 'class __FlashStringHelper'和 的错误error: forward declaration of 'class __FlashStringHelper',这意味着我做了严重错误的事情!我几乎要放弃并将字符串放入 RAM 中,但 arduino 没有太多,所以我想如果可能的话避免这种情况。有人可以帮忙吗?

c++ arduino string-comparison

4
推荐指数
1
解决办法
8897
查看次数

标签 统计

arduino ×1

c++ ×1

string-comparison ×1