I get a section type conflict if I call a macro in an inline function. There is nothing to learn about this error on the WWW.
The purpose of the macro is to propose a macro for working with strings stored in a flash for Arduino (side information only). If the function is not built-in, everything is in order. What could be the reason?
#undef PROGMEM #define PROGMEM __attribute__(( section(".progmem.data") )) #undef PSTR #if __AVR__ && __GNUC__ == 4 && __GNUC_MINOR__ > 6 typedef char prog_char; #endif #if __AVR__ && __GNUC__ == 4 && __GNUC_MINOR__ > 5 #define PSTR(s) (__extension__({static const prog_char __c[] PROGMEM = (s); \ (const prog_char_t *)&__c[0]; })) #else #define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); \ (prog_char_t *)&__c[0]; })) #endif
the code:
inline void test() { hal.console->println("AP_Common tests\n"); hal.console->println_P(PSTR("AP_Common tests\n") ); hal.console->printf_P(PSTR("AP_Common tests\n") ); } void setup(void) { test(); } void loop(void) {
Errors for: "println_P (PSTR (" Bad var table \ n "));"
AP_HAL/utility/BetterStream.h:53:57: note: in definition of macro 'printf_P' #define printf_P(fmt, ...) _printf_P((const prog_char *)fmt, ## __VA_ARGS__) ^ output_debug.h:13:26: note: in expansion of macro 'PSTR' hal.console->printf_P( PSTR("{\"t\":\"s_cmp\",\"h\":%.1f}\n"), ^ AP_Progmem/AP_Progmem_AVR.h:25:56: note: '__c' was declared here #define PSTR(s) (__extension__({static const prog_char __c[] PROGMEM = (s); \ ^ AP_HAL/utility/BetterStream.h:53:57: note: in definition of macro 'printf_P' #define printf_P(fmt, ...) _printf_P((const prog_char *)fmt, ## __VA_ARGS__) ^ AP_test.ino:60:27: note: in expansion of macro 'PSTR'
EDIT:
Calling PSTR () in twice derived classes causes the same problem. I think this is a compiler error, which leads to undefined behavior.
c arduino
dgrat
source share