设置
#define functionA(str) functionB(PSTR(str))
void functionB(char const* str) { ... something,e.g. print str... }
void functionC(char const* str) {
functionA("Hello World"); // this one work
functionA(str); // however this doesn't work
}
问题
我有一个函数function B
,我尝试使用它。如果我简单地用"some string"
来调用它,那就完美了。但是,如果我尝试在functionC
中使用参数str
进行调用,则编译器将返回错误“无效的初始化程序”和消息“正在扩展宏PSTR”。我该怎么解决,我的问题出在哪里?
编辑-其他信息
程序在AT Mega上运行,PSTR也来自AT-Mega
#define PSTR(s) ((const PROGMEM char *)(s))
#else /* !DOXYGEN */
/* The real thing. */
# define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];}))
#endif /* DOXYGEN */
#define PROGMEM __ATTR_PROGMEM__
#ifndef __ATTR_PROGMEM__
#define __ATTR_PROGMEM__ __attribute__((__progmem__))
#endif