This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Problems with inline functions
> Date: Mon, 28 Aug 2000 18:51:46 -0700
> From: George Anzinger <george@pioneer.net>
> Geoff Keating wrote:
> >
> > George Anzinger <george@pioneer.net> writes:
> >
> > > ... I think it would be nice to defer compiling
> > > inline functions until they are actually used in normal code. This
> > > would make writing header files that have inline functions MUCH easier
> > > to manage.
> >
> > This would violate the C standard. The diagnostics you're seeing are
> > required.
>
> Then the C standard says something like "non-locals in an inline
> function are references to the environment that exists at the time the
> function "appears" in the source stream"? This sounds confusing to me,
It says:
Structure, union, and enumeration tags have scope that begins just
after the appearance of the tag in a type specifier that declares the
tag. Each enumeration constant has scope that begins just after the
appearance of its defining enumerator in an enumeration list. Any
other identifier has scope that begins just after the completion of
its declarator.
It makes no special exemption for inline functions. From the point of
view of the C standard, inline functions behave just as if they were
defined normally.
> however, given that the standard says what it does, is there some neat
> trick (short of using macros) that will get the desired effect? I have
> come across cases where it was impossible to get the correct ordering
> and resorted to a dummy structure and a cast to allow a forward
> reference to a structure. (Of course, by impossible I mean without
> major rewrite of the offending header files.)
Generally, you're supposed to declare things before they are used.
With structures, this is always possible.
> In short I needed a way to forward reference a structure offset.
One possibility is to split the structures and the inline functions
out into different header files.
--
- Geoffrey Keating <geoffk@cygnus.com>