I have studied that
The inline specifier is a hint to the compiler that it should attempt to generate code [...] inline rather than laying down the code for the function once and then calling through the usual function call mechanism.
Questions:
Inlining is the process of replacing a subroutine or function call at the call site with the body of the subroutine or function being called. This eliminates call-linkage overhead and can expose significant optimization opportunities.
An inline function is one for which the compiler copies the code from the function definition directly into the code of the calling function rather than creating a separate set of instructions in memory. This eliminates call-linkage overhead and can expose significant optimization opportunities.
Remember, inlining is only a request to the compiler, not a command. Compiler can ignore the request for inlining. Compiler may not perform inlining in such circumstances like: If a function contains a loop.
It indicates the output file, i.e. what your object-file or executable should be. You can see this information by doing gcc --help or man gcc .
If optimization is turned off for the GCC compiler, is the inline specifier ignored?
Yes, if optimization is turned off in GCC, no functions would be inlined. It is equivalent to using -fno-inline
flag during compilation. See this link
-fno-inline
Don't pay attention to the inline keyword. Normally this option is used to keep the compiler from expanding any functions inline. Note that if you are not optimizing, no functions can be expanded inline.
When inline functions are called recursively, which compiler option determines the 'depth of inlining', until it follows the normal function call mechanism ?
Options max-inline-recursive-depth
and max-inline-recursive-depth-auto
. Default depth is 8.
Besides -fno-inline, you also need to use -fno-default-inline to disable inline functions in classes. This is useful when you use gdb to step into those inline functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With