Retained variables are not supported on core


I’m trying to get the attached code using retained variables to compile, but it is giving me a “retained variables are not supported on the core” error:



retained int value = 10;

void setup() {

void loop() {
Serial.println(“I’m awake!”);
value = value + 1;
Serial.println(“I’m going to sleep!”);
System.sleep(SLEEP_MODE_DEEP, 10);

I’m working in the web IDE, and have double checked that the firmware both targeted and on the device is 0.5.3. Here’s the error I’m getting:

…/hal/src/core/platform_headers.h:27:18: error: static assertion failed: retained variables are not supported on the Core
#define retained static_assert(1==0, “retained variables are not supported on the Core”);

Well, that pretty much says it anyway.

The Spark Core does not support retained variables, since it also has no VBAT pin to buffer the retained RAM.

You won’t find such a link for the Core


Thanks for ScruffR.

What’s the difference between Spark Core and Electron? This code was working fine earlier yesterday, but now nothing with retained variables compiles (I get the same error for all code fragments with retained variables). Is there a setting telling the compiler to use Core instead of Electron?

In case it’s useful, I’m trying to get this code running on the Electron.

The Electron, Photon and P1 are based on an STM32F205RG µC while the Spark Core uses an STM32F103CB which doesn’t sport that feature.

So no compiler switch will be able to alter the hardware.
But the target device setting tells the compiler what hardware (Core, Photon, P1, Electron, RPi, …) to build for and hence what features are available or not.

That’s the confusing thing. I only have Electrons (no Spark Cores), which I’ve confirmed by navigating to the devices tab in the Web IDE and only seeing only Electrons listed.

The code was compiling (and working fine) yesterday on my Electrons, but I’m now receiving compiler errors saying the target hardware isn’t an Electron.

Can you post a screenshot of your Web IDE with the targets drawer open?

Sure thing.

There should be a star symbol next to your devices (unless you inly have one) and the star of the target device should be golden.
Like here

To tag a device, hover with the mouse just left of the device name, which should reveal the star and then click it.

Ah ha–that did the trick. Thanks ScruffR!

I really appreciate your help on this.