Unable to compile new created project for STM8S board

> Executing task in folder Test STM Project: platformio run --environment stm8sblue <

Processing stm8sblue (platform: ststm8; board: stm8sblue; framework: arduino)
---------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm8/stm8sblue.html
PLATFORM: ST STM8 (1.0.3) > ST STM8S103F3 Breakout Board
HARDWARE: STM8S103F3P6 16MHz, 1KB RAM, 8KB Flash
PACKAGES: 
 - framework-arduinoststm8 0.40.181216 
 - tool-stm8binutils 0.230.0 (2.30) 
 - toolchain-sdcc 1.30804.10766 (3.8.4)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/stm8sblue/src/main.cpp.rel
Archiving .pio/build/stm8sblue/libFrameworkArduinoVariant.lib
Indexing .pio/build/stm8sblue/libFrameworkArduinoVariant.lib
Compiling .pio/build/stm8sblue/FrameworkArduino/HardwareSerial.c.rel
Compiling .pio/build/stm8sblue/FrameworkArduino/Print-float.c.rel
Compiling .pio/build/stm8sblue/FrameworkArduino/Print.c.rel
In file included from src/main.cpp:1:
In file included from /Users/user/.platformio/packages/framework-arduinoststm8/cores/sduino/Arduino.h:23:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:97:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:168:1: error: 'long float' is invalid
long double
^
In file included from src/main.cpp:1:
In file included from /Users/user/.platformio/packages/framework-arduinoststm8/cores/sduino/Arduino.h:23:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:100:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/math.h:303:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:133:26: error: 'long float' is invalid
extern int __fpclassifyl(long double);
                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:176:47: error: 'long float' is invalid
__header_always_inline int __inline_isfinitel(long double);
                                              ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:179:44: error: 'long float' is invalid
__header_always_inline int __inline_isinfl(long double);
                                           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:182:44: error: 'long float' is invalid
__header_always_inline int __inline_isnanl(long double);
                                           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:185:47: error: 'long float' is invalid
__header_always_inline int __inline_isnormall(long double);
                                              ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:188:46: error: 'long float' is invalid
__header_always_inline int __inline_signbitl(long double);
                                             ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:196:47: error: 'long float' is invalid
__header_always_inline int __inline_isfinitel(long double __x) {
                                              ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:205:44: error: 'long float' is invalid
__header_always_inline int __inline_isinfl(long double __x) {
                                           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:214:44: error: 'long float' is invalid
__header_always_inline int __inline_isnanl(long double __x) {
                                           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:228:46: error: 'long float' is invalid
__header_always_inline int __inline_signbitl(long double __x) {
                                             ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:230:9: error: 'long float' is invalid
        long double __ld;
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:249:47: error: 'long float' is invalid
__header_always_inline int __inline_isnormall(long double __x) {
                                              ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:310:8: error: 'long float' is invalid
extern long double acosl(long double);
       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:310:26: error: 'long float' is invalid
extern long double acosl(long double);
                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:314:8: error: 'long float' is invalid
extern long double asinl(long double);
       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:314:26: error: 'long float' is invalid
extern long double asinl(long double);
                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:318:8: error: 'long float' is invalid
extern long double atanl(long double);
       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:318:26: error: 'long float' is invalid
extern long double atanl(long double);
                         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
/Users/user/.platformio/packages/framework-arduinoststm8/cores/sduino/HardwareSerial.c:38:2: warning: #warning "using uart1 for HardwareSerial"
Compiling .pio/build/stm8sblue/FrameworkArduino/SPI.c.rel
Compiling .pio/build/stm8sblue/FrameworkArduino/WInterrupts.c.rel
Compiling .pio/build/stm8sblue/FrameworkArduino/WMath.c.rel
Compiling .pio/build/stm8sblue/FrameworkArduino/weak_atexit.c.rel
20 errors generated.
*** [.pio/build/stm8sblue/src/main.cpp.rel] Error 1
/Users/user/.platformio/packages/framework-arduinoststm8/cores/sduino/weak_atexit.c:13: warning 85: in function atexit unreferenced function argument : 'func'
/Users/user/.platformio/packages/framework-arduinoststm8/cores/sduino/WInterrupts.c:73: warning 85: in function attachInterrupt unreferenced function argument : 'mode'
========================================= [FAILED] Took 1.04 seconds =========================================
The terminal process "platformio 'run', '--environment', 'stm8sblue'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

At the same time example projects compiles and work fine

Rename the src/main.cpp file to src/main.c – the STM8 Arduino framework implementation is in C. If you use C++ files, there is no STM8 C++ compiler for that and it defaults to your system’s compiler. All the posted example projects use only C files.

Thanks @maxgerhardt, now it compiling but unable to link:

Archiving .pio/build/stm8sblue/libFrameworkArduino.lib
Indexing .pio/build/stm8sblue/libFrameworkArduino.lib
Linking .pio/build/stm8sblue/firmware.elf
ASlink-Warning-No definition of area SSEG
*** [.pio/build/stm8sblue/firmware.elf] Error 1

BTW is there way to teach Platform.IO to not create C++ file for STM8?

I’ve only seen this error when the C code is semantically empty. Can you add a call to e.g. delay(1000); in loop()? Seems to be a quirk of theh SDCC compiler.

The logic for that is in platformio-core/platformio/commands/home/rpc/handlers/project.py at 81c7e23ae90acf1e63996495256afcc0adcff290 · platformio/platformio-core · GitHub – if framework = arduino is set it will always create a main.cpp and not a main.c file. I’ll create an issue to address this.
Edit: Issue raised per Core creates main.cpp file for STM8 Arduino core which needs main.c · Issue #3872 · platformio/platformio-core · GitHub.