Under What condition an inline function ceases to be an inline function and acts as any other function?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The Myth:
inlineis just a suggestion which a compiler may or may not abide to. A good compiler will anyways do what needs to be done.The Truth:
inlineusually indicates to the implementation that inline substitution of the function body at the point of call is to be preferred to the usual function call mechanism. An implementation is not required to perform this inline substitution at the point of call; however, even if thisinlinesubstitution is omitted, the other rules(especially w.r.t One Definition Rule) forinlineare followed.Given the quoted fact there is a deeper context to this question.
When you declare a function as
static inlinefunction, the function acts like any otherstaticfunction and the keywordinlinehas no importance anymore, it becomes redundant.The
statickeyword on the function forces theinlinefunction to have an internal linkage.(inlinefunctions have external linkage)Each instance of such a function is treated as a separate function(address of each function is different) and each instance of these functions have their own copies of static local variables & string literals(an
inlinefunction has only one copy of these ).