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

[dub-reference/dependencies] For Have_x versions, be clear that these should ONLY be used to tell if a dependency is present #55

Open
WebFreak001 opened this issue Sep 16, 2023 · 0 comments

Comments

@WebFreak001
Copy link
Member

@schveiguy

Using the Have_x versions should have the possible drawbacks discussed.

If you use version(Have_x), then that version might be defined when importing modules from a project, even if the project does not have a dependency on x. This can lead to bizarre behaviors like versioning out symbols that look like they should be present, resulting in linker errors.

A dependency is never built with Have_x unless x is actually a dependency.

I'm not sure how to describe this in a concise or non-confusing fashion. Maybe a simple example.

The current dub documentation is very sparse on the subject.


@WebFreak001

A dependency is never built with Have_x unless x is actually a dependency.

wait do you mean that x is a direct dependency? (optional or not)

I think it would probably rather be a bug if it was included without it being a direct dependency. (optional or not)


@schveiguy

Not direct, but a dependency. The example from discord was something like:

module b; // project b
version(Have_a) int x;

And then in project a, it thinks there's an x int variable when it imports b, but when b is built, it omits that. This is because b doesn't build with Have_a as a version.

If a becomes a dependency of b, then it is OK.


@WebFreak001

ah right, a note / warning for this would probably be nice on the documentation page then.

It's probably a bug that the dependency even has that version (Have_a) statement without having a as dependency, as it would always be false then.


@schveiguy

Right, that int will never be defined. That's probably the easiest way to explain it.

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

No branches or pull requests

1 participant