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

Add inline to avoid duplicated-symbols-error #7

Merged
merged 2 commits into from
Jun 28, 2024
Merged

Add inline to avoid duplicated-symbols-error #7

merged 2 commits into from
Jun 28, 2024

Conversation

junjihashimoto
Copy link
Collaborator

If we use gpu.h in multiple files, functions other than templates will be implemented in duplicate, causing errors during linking.
This PR adds inline directive not to generate symbols in gpu.h.

C++20's module may allow the duplication.
https://medium.com/@guilhermeprogrammer/a-gentle-introduction-to-c-modules-29bbcf7ac86f

@junjihashimoto
Copy link
Collaborator Author

I tested the case of multiple files in gpu_puzzles. I haven't included the code because I prefer to keep it simple.

@junjihashimoto
Copy link
Collaborator Author

The drawback to this solution is that it's harder to hook into during debugging since there are no symbols.

Copy link
Contributor

@austinvhuang austinvhuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting for future reference. Had some discussion in discord about keeping gpu.h header-only-ish vs. separating it out to gpu.cpp for implementations / gpu.h for declarations.

since gpu.h is pretty small we'll keep it this way for now. if the header-only approach affects compile times or gets in the way of larger projects later, we may refactor to gpu.h/gpu.cpp down the road. Thanks to @junjihashimoto for pointing out the issue with weak symbols.

@austinvhuang austinvhuang merged commit ad4cb43 into AnswerDotAI:main Jun 28, 2024
@junjihashimoto junjihashimoto deleted the fix/duplicated-symbols branch June 29, 2024 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants