On Wed, Aug 31, 2022 at 11:06 AM Gregory Nutt <spudan...@gmail.com> wrote:
>
> > There used to be one defining inline to be nothing for ZDS-II .  It would
> > > only be necessary to restore it for ZDS-II. This does not fix the
> > function
> > > duplication of static inline functions in header files, however.
> >
> > Is the duplication really a problem, though?
> >
> > After all, the whole point of a static inline function is to insert
> > the code directly at the call sites, which implies duplication and
> > larger code footprint. Ostensibly static inline should only be used
> > for "very small" functions.
> >
>
> It can be and was in the past.  It depends not only on the size of the
> static inline function but also on how many are in a header file and how
> many times the header file is included.  There are 15 in ctype.h.

I suppose this is made much worse when the compiler does not
automatically remove unused functions.

There may be a way to workaround this. The idea is to put the static
inline function in a header, but wrap it with some preprocessor logic
so that when the compiler does not support static inline, it would
read an extern declaration rather than the entire function. Then, in
only one source file, the header is included immediately after
defining some IMPLEMENTATION symbol. So only in that one source file,
the compiler reads the entire function. The header may be included
from many files, but only one file will define IMPLEMENTATION (or any
desired name) before the include.

> I removed most of the others a couple of years ago (replacing them with
> macros)still , but we grew more since that PR.  But I think that the
> situation is not so bad now.
>
> Another problem (for SDCC only) is this:
> https://acassis.wordpress.com/2022/01/14/testing-nuttx-rtos-on-z80-simulator/

Ah yes the passing struct as value problem. I think standard C89 is
supposed to support that, so this is a limitation in SDCC rather than
a problem on our end?

Nathan

Reply via email to