Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Interesting, I thought if declaration is inline, then compiler automatically will assume any implementation is also should be inlined. Commented Jun 15, 2020 at 14:14
  • It gets trickier when multiple translation units are involved. 6.7.4 p10 says "An inline definition does not provide an external definition for the function, and does not forbid an external definition in another translation unit." Commented Jun 15, 2020 at 14:31
  • @IanAbbott Yes but it far beyond the level of the question. There was a copy-paste mistake as well. Commented Jun 15, 2020 at 14:53
  • @P__J__ Yes, it is easy to get confused. Indeed, I was confused by "An inline definition" because that only exists when there is no external declaration of the function in file scope. So an inline function definition will also be the externally linked definition of the function if it has an external declaration at file scope. In that case, the inline may still act as a hint to the compiler, and the function still has certain restrictions. Commented Jun 15, 2020 at 15:13
  • So the correct way is to always add the keyword at the definition and not the declaration? Commented Jul 20, 2023 at 15:11