What does 'inline' mean?

Johannes Pfau nospam at example.com
Sat Jun 13 11:35:31 UTC 2020


Am Fri, 12 Jun 2020 23:24:32 -0400 schrieb Andrei Alexandrescu:

> On 6/12/20 8:52 PM, Manu wrote:
>> Except in the case I described as case #3, in which it would be useful
>> to have SOME WAY, to 'force inline' and receive an error if it failed.
> 
> I recall a couple of compilers (TopSpeed, does anyone remember?) had
> such a feature. The warnings listing the arbitrary functions that failed
> whatever heuristics was utterly useless. No C++ compiler implements it
> today, and I don't think any should.

Doesn't GCC's always_inline do exactly that?

https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
Generally, functions are not inlined unless optimization is specified. 
For functions declared inline, this attribute inlines the function 
independent of any restrictions that otherwise apply to inlining. Failure 
to inline such a function is diagnosed as an error. Note that if such a 
function is called indirectly the compiler may or may not inline it 
depending on optimization level and a failure to inline an indirect call 
may or may not be diagnosed. 



-- 
Johannes


More information about the Digitalmars-d mailing list