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

How to handle non templated freestanding functions if there are multiple compilation units #270

Open
wirew0rm opened this issue Apr 6, 2023 · 0 comments

Comments

@wirew0rm
Copy link
Member

wirew0rm commented Apr 6, 2023

If a project using multiple compilation units, which are later linked together, linking will fail if we define any non-inline freestanding functions, because the name of the function will be present in every compilation unit that includes the opencmw headers.

Up to now we solved this by making all these functions inline, which will allow multiple definitions to exist by mangling their names (or actually inline them).

Since this actually duplicates the methods in the executable this is probably not the smartest way to do this.

@giucam also stumbled upon this and proposed a different solution which adds a precompiler definition to decide whether the function should be declared or defined in this compilation unit, see #264. Since this is a bit non-intuitive from a user perspective we setteled to first change them to inline (#266) which is in line what we do elsewhere in the project and then discuss what to do next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 Ideas (∞)
Development

No branches or pull requests

2 participants