I'm coding my 3rd testing project on stm8, to be exact in 2 different mcus, 103 and 105. I'm using cosmic compiler, and i didnt have any problem with the previous 2 projects (because i didnt verify the size).
The problem is that binary files generated by cosmic linker are oversized,... I expain it.
Until now ( I have more than 25 years programming and 13 years in MCU's world) when you included functions and you didnt use them, the linker was able to remove them from final binary since they are not being used..., I say until now because cosmic compiler is not doing that.
In my 3rd testing project i wanted to create the bigger array in flash (with const char noname[xxx];, where xxx is the size). What was my surprise when with a small code (about 10 lines my code, basically initializing ports and timers) the bigger table size that I was able to create in a 8kb flash stm8s103 was just 3300... I though then that i did something wrong so i started to do different tests...., I called my provider and he started to do his own tests, after a while we talked again and our conclusion was that COSMIC compiler doesn't remove unused functions.
To verify it, just create a cosmic project with stvd, then include for example in the project stm8_gpio.c, generate a map file (linker tab then output in category combobox). You will see a .map file generated and a line, something like:
After that I edit the stm8s_gpio.c file and remove with a #if defined(XXXX) the function GPIO_ExternalPullUpConfig that i'm not using in my code, and i get:
So basically it is including the function, even when I dont use it in the code
If you continue reading the programmer.map file in the first case you will see
Maybe the problem is that i'm using the 32kb limited version of the compiler but at least they can notice you this "hidden feature" when you get it.