Hello,
please consider this very simple code ; not a real life application, but I've been facing this problem for a long time, and it shows the problem.
void setup()
{
Serial.begin(115200);
}
inline int dummy() { return 0; }
void loop()
{
//static bool done = false;
//static int x;
//if (!done)
//{
// x = dummy();
// done = true;
//}
static int x = dummy();
Serial.println(x);
delay(1000);
}
Compiled for STM32F103C Series, with Arduino IDE, and with default options, the binary is 11604 bytes
Compile the same code with VisualMicro/Visual Studio, default options, release. The binary is now 74776 bytes !!!!!! Needless to say that such a program cannot be flashed on a regular BluePill (genuine STM32 = 64KB if not "unlocked", or chinese 64K clones)
Bootloader : "Roger's Core"
As soon as a static variable is initialized with a function within a function, the binary becomes insanely huge... (the commented code is a workaround). Inlined or not, the problem remains the same.
There's probably some offending parameter in the compiler and/or linker command, but I have no idea.
Visual Studio 2017, Arduino IDE 1.8.10, VisualMicro 1909.27.0