Browse Source

Workaround for strict aliasing warnings with -O2

teensy4-core
PaulStoffregen 7 years ago
parent
commit
8a02ea67f5
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      teensy3/avr/pgmspace.h

+ 16
- 0
teensy3/avr/pgmspace.h View File

@@ -77,9 +77,25 @@ typedef uint64_t prog_uint64_t;
#define fprintf_P(fp, ...) fprintf((fp), __VA_ARGS__)

#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#if 0
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))
#else
#define pgm_read_word(addr) ({ \
typeof(addr) _addr = (addr); \
*(const unsigned short *)(_addr); \
})
#define pgm_read_dword(addr) ({ \
typeof(addr) _addr = (addr); \
*(const unsigned long *)(_addr); \
})
#define pgm_read_float(addr) ({ \
typeof(addr) _addr = (addr); \
*(const float *)(_addr); \
})
#endif


#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)

Loading…
Cancel
Save