cancel
Showing results for 
Search instead for 
Did you mean: 

STM8 Cosmic: "weak" function

Arlleex1
Associate II

Hello!

The Cosmic compiler supports "weak" functions to override them in the future?

4 REPLIES 4
AvaTar
Lead

Yes.

Not limited to the "Cosmic" compiler, a label defined as "weak" might appear twice in a project.

In other words, the label can appear once, or twice with one occurence defined as "weak". In the latter case, the non-weak definition takes precedence.

This is e.g. used to supply default implementation for interrupt handlers.

Arlleex1
Associate II

Thanks for the answer!

As a matter of fact, I wanted to find the syntax [weak] for STVD / Cosmic for STM8. The CXSTM8 documentation did not find this =(

I did a project for a STM8 several years ago, with another toolchain (forgot its name ...).

Not sure who "invented" it, but the "weak" attribute is supported by all gcc-based toolchains for ARM/Cortex M, and AFAIK also the Keil and IAR one's.

The "weak" support includes the assembler and linker as well.

S.Ma
Principal

weak should be used when there is no other implementable way, because it is like a pandora box. You mayl see it as making your life easier at first...