I got:
#include <inttypes.h>
typedef struct dbg_s dbg_t;
struct dbg_s{
const uint8_t size;
const uint8_t* item;
};
#define DBG_SIZE 2
const uint8_t const dbgItems[DBG_SIZE] PROGMEM = {1,2};
const dbg_t const dbgMenu = {DBG_SIZE, dbgItems};
const dbg_t* ptr_global = &dbgMenu;
void dbg_init(void){
const dbg_t* ptr_local = &dbgMenu;
}
what results in the watch of:
Name Value Type
ptr_global 0xc47b dbg_t*{prog}@0x0000
ptr_local 0x0241 dbg_t*{data}@0x21f1 ([R28]+1)
dbgMenu {dbg_t(data)@0x0241} dbg_t{data}@0x0241
Notice the local pointer points to the correct location and the global points anywhere, although I intended to point both to the prog-location. Why is the local pointer correct and the global pointer fails?
#include <stdint.h>is supplied,const uint8_t const dbgItems[DBG_SIZE] PROGMEM = {1,2};gets a compiler error due to incorrect grammar—afterdbgItems[DBG_SIZE], the compiler expects;or=, notPROGMEM. If there are missing macro definitions, from your own code or some other header, a minimal reproducible example should include them.ptr_globalcorrect then? If so, I'm guessing there is a buffer overrun that corrupts theprt_global's value.