Can't compile code for stm8, missing intrinsics.h

When i try to compile empty code for stm8s103f3p6 i get an error saying that it can’t find intrinsics.h dependency and unsupported compiler, i opened an empty project for arduino uno instead and it compiled without any errors or warnings, i’m not sure what’s the problem2021-02-20_00-03

Full platformio.ini?

2021-02-21_01-01

The STM8 Arduino implementation is written in C for SDCC, since that platform has no C++ compiler. (Also noted in Build fails with "unsupported compiler"/"intrinsics.h" · Issue #4 · platformio/platform-ststm8 · GitHub).Thus you must rename main.cpp to main.c.

Also, the setup() and loop() functions must not be empty, otherwise this will trigger an SDCC linker error. (noted in New Project Buid Failed even after main.ccp -> main.c · Issue #21 · platformio/platform-ststm8 · GitHub). It seems that especially a call to delay() must be made at one point.

It’s best to follow the example projects at platform-ststm8/examples at develop · platformio/platform-ststm8 · GitHub for this case.

Example code

#include <Arduino.h>

#define LED_PIN 0 /* corresponds to PA1 */ 
/* see https://github.com/tenbaht/sduino/blob/0ce7e4c381028f6472eb29e8459210cee90b937d/sduino/stm8/variants/standard/pins_arduino.h#L41-L58*/

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(1000); 
  digitalWrite(LED_PIN, LOW);
  delay(1000); 
}

I get 3 warnings, but now it compiles successfully

thanks

Hi Folks, to remove/move the warnings i had to add build flags to platformio.ini file (while using sdcc for my stm8s103xx board).

build_flags =
-D __SDCC
-I /home//.platformio/packages/toolchain-sdcc/share/sdcc/include

__SDCC is optional because and i would actually comment out the #include <intrinsics.h>, but that is not a portable solution so… pick your poison :slight_smile: OK so why…
Because my stm8.h had a #include <intrinsics.h> inside this was causing a squiggly warning. This squiggly was for another compiler (IAR) so why you ask did it effect my sdcc build? Because __SDCC is defined by and when the compiler runs, you now of course get a warning “__SDCC redefined” in your build output, or if your never going to use IAR for your stm8, just comment #include <intrinsics.h> out of stm8s.h and leave a comment as to why.
I also needed to -Idir the include path for my sdcc compiler, using “quick fix” added paths to the wrong place e.g. “/c++/9/…”

see, Redirecting...