Crossfire Archive
[Date Prev][Date Next][Thread Prev][Thread Next]

Re: CF: crossfire code directions.

On Thu, Aug 21, 1997 at 09:24:24PM -0700, Mark Wedel wrote:
>  inline functions would probably be safer than macros (and should be just as
> fast).  Unfortunately, I don't think they are part of ANSI C, although most
> every compiler supports them.

If there is a portable way to utilize inline functions...ok.

The man page of Solaris 2.5's cc suggests that there is no way to declare
a function to be inline only. The compiler is supposed to automatically
choose which functions to inline. But to detect functions that cannot be
inlined it should be sufficient to use gcc with -Winline.

So I suggest to create a header file to be included everywhere like this:
#ifndef __GNUC__
#define __inline__

__inline__ static void SET_SPEED (...


gcc will not issue code for static inline functions that are not
referenced any more due to inlining. But I just tried the cc from
Solaris 2.5, and although it inlined the function automatically
(with -xO4), the function was not eliminated. This means that, if you
have many source files, the code of the inline functions would be
duplicated many times. A solution would be to use a better compiler
like gcc.

There may be other problems with other compilers. But the code should
be portable at least.

Any comments on this?

[to unsubscribe etc., send mail to ]

Follow-Ups: References: