> hello all,
>
> apparently it is possible to overload functions in SDCC for STM8, as
> shown recently in the getchar() implementation in one of the previous
> mails. Is this something that can also be done with C routines in a
> project? If yes, is there something like a "__weak" attribute to tell
> the linker which function to use?
>
> Thanks a lot in advance!
>
> Regards, Georg

Hello Georg,

'Overloading' can only be done for functions that reside in a library. The
linker will first link all sources (actually .rel files a.k.a. objects) it
was given and after that it will search missing symbols in the libraries.
So if you provide getchar() in your sources there is no need to search for
it in the libraries and yours will be used.

This also means that all code in your object files is linked in whether
it's used or not. And objects in the libraries that are not referenced are
not linked in. Also note that all functions in an object are linked in,
not just the missing one.

Maarten



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to