Bots, Bureaucrats, Interface administrators, smwadministrator, smwcurator, smweditor, Administrators
2,558
edits
Timo.stripf (talk | contribs) |
Timo.stripf (talk | contribs) |
||
| Line 36: | Line 36: | ||
* '''GCC & Clang/LLVM''': Both compilers support <code>__attribute__((always_inline))</code>, ensuring that a function is inlined even when optimizations are disabled. If inlining is not possible (e.g., due to recursion or taking the function’s address), an error or warning is emitted. | * '''GCC & Clang/LLVM''': Both compilers support <code>__attribute__((always_inline))</code>, ensuring that a function is inlined even when optimizations are disabled. If inlining is not possible (e.g., due to recursion or taking the function’s address), an error or warning is emitted. | ||
* '''MSVC''': Offers the __forceinline keyword, which strongly suggests inlining but does not guarantee it. If inlining is not feasible, the function remains out-of-line, and the compiler may issue a warning. | * '''MSVC''': Offers the __forceinline keyword, which strongly suggests inlining but does not guarantee it. If inlining is not feasible, the function remains out-of-line, and the compiler may issue a warning. | ||
=== No Inline === | |||
In some cases, it is beneficial to prevent a function from being inlined, such as when debugging, reducing code bloat, or avoiding unintended performance regressions. Most compilers offer explicit mechanisms to disable inlining: | |||
* '''GCC & Clang''': Both support <code>__attribute__((noinline))</code>, which ensures that a function is never inlined, regardless of optimization settings. Additionally, the compiler flag <code>-fno-inline</code> can be used to disable inlining globally. | |||
* '''MSVC''': Provides the <code>__declspec(noinline)</code> attribute to prevent function inlining. The compiler option <code>/Ob0</code> disables all inlining, even for functions marked as <code>inline</code>. | |||
=== GCC (GNU Compiler Collection) === | === GCC (GNU Compiler Collection) === | ||
edits