Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] inlining functions
Home

[Freeciv-Dev] inlining functions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] inlining functions
From: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Date: Fri, 17 Aug 2001 20:03:50 -0400

I looked over previous discussions about inlining functions, and I think
inlining functions is better.

An inlined function should be as fast as a macro.  Although this may not
be the case for all compilers, we should let the compiler people worry
about it.

For any platforms (compilers) which don't support inline, we use
#defines to ignore inline so that things will compile cleanly.  It looks
like configure already takes care of this.

Inline is in the ANSI C '99 standard, and should be supported by
most/all compilers.  No example is given of a compiler that doesn't
support inline.

Tony Stuckey points out that "GCC doesn't do cross-procedural
optimization, nor cross-source-file inlining of small functions", and so
macros are better [1].  Again, I think this is a compiler issue.

In summary, after it was pointed out that inlining *might* not provide
as much speed benefit as using a macro, it looks like the discussion was
pretty much dropped.  No profiling is done comparing the two AFAICT.

Doing some external research, it looks like a C++ compiler may balk at
the same inline definition configure generates for C code [3].  All
other "complaints" I found about unsupported inline were from years ago.

Finally, I read about a GCC option, "-finline-functions", that will
cause small functions to be inlined automatically.

[1] http://arch.freeciv.org/freeciv-dev-200101/msg00077.html
[2] http://arch.freeciv.org/freeciv-dev-200101/msg00087.html
[3] http://csf.colorado.edu/archive/1998/mozilla-unix/msg00164.html

jason


[Prev in Thread] Current Thread [Next in Thread]