Inline CPP functions in inl files #1270
Open
+192
−192
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog
Add inline keywords to all definitions in C++ inl files
Docs
Description
None of the function definitions in the C++ .inl files had the "inline" qualifier. So I was including them with the headers, and getting many double-include errors. Adding inline to the function declarations fixes this, and should be more idiomatic C++ since these have the .inl extension.
Missing these isn't a huge deal for smaller projects but causes issues with the address sanitizer and linkers when this repo is a part of a library.
I tested this in a proprietary project that included the
mcap/reader.hpp
andmcap.writer.hpp
in a module that was compiled to a shared library. It was built with CMake, using thetarget_include_directories
on themcap/cpp/mcap/include/mcap
directory. That shared library was linked against a target. The linker also pulled a copy of the MCAP library into the binary, which led to a one-definition-rule violation.Inlining these functions caused that issue to disappear, and also reduced binary size.