fix: remove redundant lantern.h include causing macro redefinition warning#1430
Merged
fix: remove redundant lantern.h include causing macro redefinition warning#1430
Conversation
…n warning device.cpp was the only source file that directly included lantern/lantern.h before torch.h. Since torch.h already includes lantern/lantern.h (with the correct LANTERN_API weak linkage definition), the redundant include caused a -Wmacro-redefined warning for LANTERN_API.
64a8afe to
e83c37c
Compare
device.cpp was the only source file that directly included lantern/lantern.h before torch.h. This caused a -Wmacro-redefined warning because lantern.h defined LANTERN_API as empty, then torch.h redefined it with weak linkage. That direct include also happened to provide the lanternInit() function definition (compiled when LANTERN_HEADERS_ONLY is not set). Move this responsibility to lantern.cpp where lanternInit() is actually called, and add #undef LANTERN_API in torch.h so the weak linkage override is clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
#include <lantern/lantern.h>fromdevice.cpp, which was the only source file with this extra includetorch.halready includeslantern/lantern.hwith the correctLANTERN_APIweak linkage definition; the earlier direct include definedLANTERN_APIas empty, thentorch.hredefined it as__attribute__((weak)), triggering-Wmacro-redefinedTest plan
pkgbuild::compile_dll()compilesdevice.cppwith no warnings