This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: inline?
- From: Jeff Johnston <jjohnstn at redhat dot com>
- To: "Artem B. Bityuckiy" <abityuckiy at yandex dot ru>
- Cc: newlib at sources dot redhat dot com
- Date: Fri, 02 Apr 2004 16:53:40 -0500
- Subject: Re: inline?
- References: <406D794B.3090404@yandex.ru>
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.