Setup
#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
}
Problem
I have a function function B
which I try to use. If I simply call it with "some string"
it works perfectly. However if I try to call it in functionC
with the argument str
, the compiler returns the error "invalid initializer" and the message "in expansion of macro PSTR". How can I fix this, where is my problem?
EDIT - additional information
The program runs on an AT Mega and the PSTR is also from 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