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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2018
Merged

Workaround strict-aliasing warnings #996

merged 1 commit into from
Jan 17, 2018

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 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