POV-Ray : Newsgroups : povray.tools.general : tga->df3 : Re: tga->df3 Server Time
1 Jun 2024 19:47:36 EDT (-0400)
  Re: tga->df3  
From: Ross
Date: 5 Oct 2004 10:58:44
Message: <4162b6a4$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:41629234@news.povray.org...
> Ross <rli### [at] everestkcnet> wrote:
> > besides being required in order to have the compiler consider inlining
it?
>
>   Quite ironically, most compilers completely ignore the 'inline' keyword
> when they evaluate whether a function is worth inlining or not. That is,
> the 'inline' keyword has usually no effect whatsoever on the probability
> of a function being inlined.
>   In this context 'inline' is exactly as obsolete as eg. 'register' (which
> compilers completely ignore).
>
>   However, unlike 'register', 'inline' is an essential keyword, but for a
> rather different reason than inlining.
>
>   When you declare a function 'inline', you are telling the compiler
> "if the implementation of this function appears in more than one object
> file, the linker must merge them to one".
>
>   Normally if the implementation of a certain function appears in two
> different object files being linked to the same binary, the linker will
> issue an error message: The linker can't know which one of them to use.
>   However, if you had declared the functions 'inline', the compiler will
> instruct the linker that both implementations are actually the same and
> the linker will then use one of them.


Ah, this is actually covered in Scott Meyers book "Effective C++". It's a
good book, but it takes a few reads, atleast for me, and a few projects to
have things stick. This was the first project i've done since reading the
book.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.