8000 Workaround strict-aliasing warnings by Lauszus · Pull Request #996 · espressif/arduino-esp32 · GitHub
[go: up one dir, main page]

Skip to content

Workaround strict-aliasing warnings#996

Merged
me-no-dev merged 1 commit intoespressif:masterfrom
Lauszus:pgmspace
Jan 17, 2018
Merged

Workaround strict-aliasing warnings#996
me-no-dev merged 1 commit intoespressif:masterfrom
Lauszus:pgmspace

Conversation

@Lauszus
Copy link
Contributor
@Lauszus Lauszus commented Jan 14, 2018

@stickbreaker
Copy link
Contributor

@Lauszus looks like it works! Here is my test code:

#include <pgmspace.h>
/* remove
8000
 these comments to test new code
#undef pgm_read_word(addr)

#define pgm_read_word(addr) ({ \
  typeof(addr) _addr = (addr); \
  *(const unsigned short *)(_addr); \
})
*/
const PROGMEM  uint16_t charSet[]  = { 65000, 32796, 16843, 10, 11234};

const unsigned short sh=7;
void setup(){
  unsigned short a = pgm_read_word(&sh);
  Serial.begin(115200);
  Serial.printf(" a =%d\n",a);
  for(uint8_t b=0; b<(sizeof(charSet)/sizeof(uint16_t)); b++){
    a = pgm_read_word(&charSet[b]);
    Serial.printf(" a =%d\n",a);
    }
}

void loop(){}

output: with existing progmem

 a =7
 a =65000
 a =32796
 a =16843
 a =10
 a =11234

output: with proposed changes to progmem

 a =7
 a =65000
 a =32796
 a =16843
 a =10
 a =11234

Chuck.

@me-no-dev me-no-dev merged commit 78acedd into espressif:master Jan 17, 2018
@me-no-dev
Copy link
Member

merged :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0