Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Inline function
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Restrictions == Taking the address of an <code>inline</code> function requires code for a non-inlined copy of that function to be emitted in any case. In C99, an <code>inline</code> or <code>extern inline</code> function must not access <code>static</code> global variables or define non-<code>const</code> <code>static</code> local variables. <code>const static</code> local variables may or may not be different objects in different translation units, depending on whether the function was inlined or whether a call was made. Only <code>static inline</code> definitions can reference identifiers with internal linkage without restrictions; those will be different objects in each translation unit. In C++, both <code>const</code> and non-<code>const</code> <code>static</code> locals are allowed and they refer to the same object in all translation units. gcc cannot inline functions if<ref name="gcc-inline"/> # they are [[variadic function|variadic]], # use <code>[[alloca]]</code> # use computed <code>goto</code> # use nonlocal <code>goto</code> # use [[nested function]]s # use <code>setjmp</code> # use <code>__builtin_longjmp</code> # use <code>__builtin_return</code>, or # use <code>__builtin_apply_args</code> Based on Microsoft Specifications at MSDN, MS Visual C++ cannot inline (not even with <code>__forceinline</code>), if # The function or its caller is compiled with /Ob0 (the default option for debug builds). # The function and the caller use different types of [[exception handling]] (C++ exception handling in one, structured exception handling in the other). # The function has a [[variable argument list]]. # The function uses [[inline assembly]], unless compiled with /Og, /Ox, /O1, or /O2. # The function is [[Recursion (computer science)|recursive]] and not accompanied by <code>#pragma inline_recursion(on)</code>. With the pragma, recursive functions are inlined to a default depth of 16 calls. To reduce the inlining depth, use <code>inline_depth</code> pragma. # The function is [[virtual function|virtual]] and is called virtually. Direct calls to virtual functions can be inlined. # The program takes the address of the function and the call is made via the pointer to the function. Direct calls to functions that have had their address taken can be inlined. # The function is also marked with the naked <code>__declspec</code> modifier.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)