guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Patch] inline.h should not define inline functions with "extern" li


From: Marius Vollmer
Subject: Re: [Patch] inline.h should not define inline functions with "extern" linkage
Date: Fri, 12 Sep 2003 16:13:37 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Matthias Koeppe <address@hidden> writes:

> I am now building Guile from CVS HEAD with a version of the Sun Forte
> C compiler that supports the "inline" keyword.  
>
> The "inline" keyword does not imply static linkage, and in fact
> inline.h defines the functions `scm_cell' and `scm_double_cell'
> explicitly with "extern" linkage.  
>
> Therefore, every file that includes inline.h defines a copy of these
> two functions, each copy with external linkage.  This makes it
> impossible to link Guile.  (I do not know why this would work with
> gcc; it is definitely wrong.)
>
> The patch below fixes it.  inline.c defines the functions with
> external linkage, and every file including inline.h defines static
> inline copies.

We should keep the "extern inline" when compiling with GCC, it is the
Right Thing to do.  For non-GCC compilers, we can use "static inline".

I have changed the code in inline.h to, for example

    #if defined SCM_C_INLINE && ! defined SCM_INLINE_C_INCLUDING_INLINE_H
    /* definitely inlining */
    #ifdef __GNUC__
    extern
    #else
    static
    #endif
    SCM_C_INLINE
    #endif
    SCM
    scm_double_cell (scm_t_bits car, scm_t_bits cbr,
                     scm_t_bits ccr, scm_t_bits cdr)
    {
       ...

Ok?

> The same trick needs to be applied to the external/inline functions
> in numbers.h.  The patch fixes them as well.

I think we can leave numbers.h alone.  The inline functions are not
part of the public API and it is not important that they are inlined
outside of numbers.c, so we don't need to put them into a header file.

We could make them "static inline", with a little bit of work.  Would
that be worthwhile?

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405




reply via email to

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