0

may I to compile inline a function, which has not been declared with inline keyword .?

/* can write here "inline" */ void this_function ( ) 
{
    return ;
}

int main ( void )
{
    this_function () ; // here this function must be compiled as inline
    this_function () ; // but not here ; now it must be called
}

E.F.P.E.

Volodymyr Boiko
  • 1,533
  • 15
  • 29
  • I don't understand your question, are you asking if it is possible to tell the compiler to inline some specific function calls, but not others? (possibly for the same function?) If so, i don't think you should worry about this. The "inline" keyword in C++ is only some kind of "recommendation" but doesn't force the compiler to inline the function (you can use -Winline with clang or gcc to know whether such functions haven't been inlined though) and it's usually simpler to let the compiler decide which functions to inline and not use this keyword for optimization purposes. – Caninonos Aug 02 '15 at 17:24
  • You may want to read the answers of these related stackoverflow questions: [Where should I write the keyword 'inline for a function/method?](http://stackoverflow.com/questions/1759300/when-should-i-write-the-keyword-inline-for-a-function-method); [Benefits of inline functions in C](http://stackoverflow.com/questions/145838/benefits-of-inline-functions-in-c) – Caninonos Aug 02 '15 at 17:27
  • @Caninonos , you understand me right. but is there any instruments to force inlining certain function calls .? – Volodymyr Boiko Aug 02 '15 at 18:09
  • 1
    I don't think there is such a thing (at least in C or in C++). As far as i know, there are no keywords, even `inline`, which may force the compiler either to inline or not to inline a function. And if that's true, there obviously can't be any which may force the compiler either to inline or not to inline specific function calls. But if those doesn't exist, it's because the compiler usually does a much better job while determining whether one function call should be inlined or not. Are you sure you really need those? – Caninonos Aug 02 '15 at 18:26

0 Answers0