Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple definition of `refl::runtime::detail::next_depth(int)' #33

Closed
james-conrad opened this issue Jul 11, 2020 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@james-conrad
Copy link
Contributor

When including refl.hpp from more than one source file using gcc 7.5.0, the compiler complains that refl::runtime::detail::next_depth(int) is defined multiple times.

g++ -I./src -MMD -MP --std=c++17 -c src/Effect.cpp -o build/./src/Effect.cpp.o
g++ -I./src -MMD -MP --std=c++17 -c src/main.cpp -o build/./src/main.cpp.o
g++ -I./src -MMD -MP --std=c++17 -c src/Object.cpp -o build/./src/Object.cpp.o
g++ ./build/./src/Effect.cpp.o ./build/./src/main.cpp.o ./build/./src/Object.cpp.o -o build/a.out
./build/./src/main.cpp.o: In function `refl::runtime::detail::next_depth(int)':
main.cpp:(.text+0x0): multiple definition of `refl::runtime::detail::next_depth(int)'
./build/./src/Effect.cpp.o:Effect.cpp:(.text+0x0): first defined here
./build/./src/Object.cpp.o: In function `refl::runtime::detail::next_depth(int)':
Object.cpp:(.text+0x0): multiple definition of `refl::runtime::detail::next_depth(int)'
./build/./src/Effect.cpp.o:Effect.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
Makefile:17: recipe for target 'build/a.out' failed
make: *** [build/a.out] Error 1

Moving the function into an anonymous namespace or declaring it static (both of which force internal linkage) resolves the issue.

james-conrad added a commit to james-conrad/refl-cpp that referenced this issue Jul 11, 2020
Move runtime::detail::next_depth into anonymous namespace.

This addresses veselink1#33
@veselink1 veselink1 added the bug Something isn't working label Jul 11, 2020
@veselink1
Copy link
Owner

Thanks! Merged in c23c2bb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants