3 ms·
If you textually define a function "inline" in an header file yet do not mark it inline, you are duplicating it in every point where the declaration is imported
by gpderetta 2y ago
If you textually define a function "inline" in an header file yet do not mark it inline, you are duplicating it in every point where the declaration is imported, yet, not being inline for linkage purposes, you will get compilation errors.
Member and template functions are special cased to be implicitly inline.
- mgaunard 2y agoThat's not an inline definition, that's a normal definition, which should never be in a header file. Non-inline definitions need to be in their own translation unit.
- gpderetta 2y agoOf course, but that disproves that an "inline definition is a definition that is provided inline with a declaration" [in an header file]. An inline definition is a definition that is marked inline, implicitly or explicitly. Whether it is defined together with the declaration or in an header vs translation unit is immaterial.