inline?

Jeff Johnston jjohnstn@redhat.com
Sat Apr 3 00:43:00 GMT 2004


Artem B. Bityuckiy wrote:
> Hello.
> 
> Newlib tries to take care about K&R compatibility. For example, "_CONST" 
> macro is used instead of "const" modifier, etc. Is it K&R-compatible to 
> use "inline" modifier? Is there some wrapper for "inline" ?
>

inline is an extension and may be treated as more of a hint in later C 
compilers.  It is not ANSI and I would not expect a K&R compiler would support 
it though I cannot speak from experience.

> Also, isn't it more efficient to use "inline" directives for those 
> functions, who has reentrant analog? These functions consist of on call 
> to reentrant "brother". Isn't "inline" usage disagree C standards where 
> function's prototypes are rigidly defined?
> 

You are not going to save a lot using this strategy.  When you think of the 
additional space that is required, there is minimal gain.  The functions may 
also be called infrequently.  If the compiler actually accepts your hint to 
inline the function, you are nearly doubling the size of any statically linked 
application since many of these cases involve the non-reentrant function simply 
having a call to the reentrant version.  For embedded platforms tight on space, 
this is clearly unacceptable.  If the function itself does a fair amount of 
processing, the small amount of code you save at runtime would not create a 
meaningful gain.

-- Jeff J.



More information about the Newlib mailing list