Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By jcmvbkbc
#17246
Code: Select allint fubar(void) {

  return random(100);
}

void setup() {
  delay(5000);
  Serial.begin(115200);
  char *foo;
  foo=(char *)&fubar;
  Serial.print("Addr: ");
  Serial.println((unsigned long )foo,HEX);
  Serial.print("Value: ");
  Serial.println((byte)*(unsigned long*)foo);     // <-- should not reboot here provided that foo is aligned.
}
User avatar
By jcmvbkbc
#17250
ReinholdHiller wrote:But it does.

Addr: 40210834
Value:

ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset

Ok, one more attempt. The compiler gets unexpectedly smart sometimes.
Code: Select allint fubar(void) {

  return random(100);
}

void setup() {
  delay(5000);
  Serial.begin(115200);
  char *foo;
  foo=(char *)&fubar;
  Serial.print("Addr: ");
  Serial.println((unsigned long )foo,HEX);
  Serial.print("Value: ");
  Serial.println((byte)*(volatile unsigned long*)foo);     // <-- does not reboot here provided that foo is aligned.
}