Talk:Inline function

Language Support
The article points the reader to "below" in the Language Support section with the following text "(see below for a problem in C99 regarding this definition)" (which I removed) while there is no relevant text that points to the promised problem. Neither is the "below" clear about whether the reader is supposed to expect a link or a text exposition or a complete section. Please fix. EaswarH 17:43, 25 January 2012 (UTC) — Preceding unsigned comment added by Easwarno1 (talk • contribs)

"in-line" vs. "inline"
The article seems inconsistent in the usage. Is there any diference between the two? Is 'inline' an adjective and 'in-line' a verb? I'll clean it up if I find out the rule.


 * They seem to be used interchangably. In certain contexts, such as "inline function", one spelling tends to prevail. The "in-line" spelling is somewhat older and more traditional. Most of the time "inline" is fine and understandable in just about any place. I don't know any hard and fast rule, and I don't think the part-of-speech one is true. Maybe someone else can shed more light on it. Derrick Coetzee 21:46, 26 Oct 2004 (UTC)


 * The language keywords in both C++ and C99 are "inline", and personally I encounter "inline" much more often than I do "in-line". Although of course that's not definitive evidence, I'd vote for using "inline" consistently. Neilc 08:17, 28 May 2005 (UTC)


 * no --Windymager 18:10, 3 December 2006 (UTC)

most used?
C++, C99, and GNU C each have support for inline functions, although 1989 ANSI C, the dialect of C most commonly used in practice, does not. I doubt the bold statement of ansi being more used in practice, to be true. I see no reference and thus propose to eliminate it. 217.140.108.2 10:48, 14 September 2007 (UTC)


 * Well, C++ is not a C dialect so we can remove that from the equation straight away. We then have C89, C99 and GNU C.  There are very few fully conforming C99 compilers out there - they are still mainly 'C89+'.  The GNU extensions do receive some use on Unix, but less so on other platforms.  Even on Unix many coders/management policies are unwilling to use them since GCC is far from universal even on Unix.  The impression I have is that C89 still leads by a mile.  Put it another way: what dialect do you think is more prevalent? 86.130.81.171 (talk) 11:49, 26 June 2008 (UTC)

The statement Most other languages, including Java and functional languages, do not provide inline functions ... is not true; Common Lisp has support for inline functions and I think other functional languages has too. —Preceding unsigned comment added by 90.149.36.67 (talk) 01:19, 12 September 2008 (UTC)

Macros and return
... you cannot make the macro return something which is not the result of the last expression invoked inside it.

This is not entirly true. You can still use the chaining operator (however I haven't tested it for every compiler out there).

Example:
 * #define f1(a,b) (a+b)
 * #define f2(a,b) (a=f1(a,b),a-b)

This will execute a=a+b and return (a+b)-b instead of the result f1 (a+b). Used especially when you want to do heavy pointer arithmetic or while using reference types as arguments.

213.150.1.132 (talk) 12:27, 2 April 2010 (UTC)

Excessively or insufficiently C-centric.
In some places this article seems like it's implicitly about the inline keyword in C++ and some versions of C (for example, the opening paragraph stipulates that "it is a request made to the compiler, not an order", but obviously a language could exist that allows for an "order"), and in other places it seems like it's trying to be language-neutral (for example, the "language support" section discusses C/C++ in one sentence, then Ada in the next).

We could address this in two ways:
 * make it less C-centric. For any claim X that can't be proven to apply to all languages with such a feature, we either remove claim X, or we indicate exactly which language(s) claim X applies to.
 * make it more C-centric. We already have a language-neutral article, after all: Inline expansion. This article could still have a section that discusses other languages, in order to put the C/C++ feature in context, but that would be clearly demarcated as the purpose.

My preference is the latter approach, if only because it's easier to do — the article is already very much focused on C/C++ — but I'm also O.K. with the former approach, if people prefer it for whatever reason.

—Ruakh TALK 19:54, 18 October 2010 (UTC)

INLINE FUNCTION: Inline function is the optimization technique used by the compilers. Function prototype to make a function inline. Inline function instruct compiler to insert complete body of the function wherever that function got used in code.

ADVANTAGES :- 1) It does not require function calling overhead. 	2) It also save overhead of variables while function calling. 5) This is the most important one, in this way compiler can now focus on dead code elimination.

DIS-ADVANTAGES :- 1) It may cause compilation overhead as if somebody changes code inside inline function than all calling location will also be compiled. 	2) If used in header file, it will make your header file size large and may also make it unreadable. 3) It’s not useful for embedded system where large binary size is not preferred at all due to memory size constraints. NEESHA — Preceding unsigned comment added by 49.205.227.105 (talk) 06:44, 18 January 2014 (UTC)

#pragma function / function pragma restrictions
msdn says #pragma function(func_name) will disable inlining of given function. https://github.com/MicrosoftDocs/cpp-docs/blob/main/docs/preprocessor/function-c-cpp.md https://learn.microsoft.com/en-us/cpp/preprocessor/function-c-cpp?view=msvc-170 2600:4040:B63E:1C00:FD65:D0A0:D502:CC87 (talk) 13:59, 5 November 2023 (UTC)