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.

4
  • What is inline required for in C++ then at all? wouldn't include guards be totally sufficient? Commented Jun 27, 2017 at 11:03
  • 1
    @dhein - Include guards protect you from double inclusion in the same translation unit. But headers are meant to be included freely in separate translation units. When the resulting object files are linked, you'd get an ODR violation, unless the compiler was informed it's an inline function. Commented Jun 27, 2017 at 11:07
  • Oh, wait... I got it! Since which C++ this is included in the standard? I remember having encountered such a problem in a private project some years ago.... My teacher explained me to use prototypes for the functions to make my project work again. That helped for some time but just made the mess worse later on and I just dropped the project. I feel like digging it up again to see if this would have solved it back then. Commented Jun 27, 2017 at 11:15
  • 2
    @dhein - Since C++98. Originally also "a hint to the compiler" that the functions entire body should be inlined, but that is now deprecated. The linkage ramifications remain however, and are very important. Commented Jun 27, 2017 at 11:19