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

ImportC: automatically #include importc.h #14121

Merged
merged 1 commit into from
May 14, 2022

Conversation

WalterBright
Copy link
Member

Each preprocessor does it differently.

@WalterBright WalterBright added the Feature:ImportC Pertaining to ImportC support label May 13, 2022
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#14121"

ljmf00
ljmf00 previously requested changes May 14, 2022
auto f = FileName.combine(entry, "importc.h");
if (FileName.exists(f) == 1)
{
importc_h = f;
Copy link
Member

Choose a reason for hiding this comment

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

Where did you clean this? It is going to leak.

Copy link
Member Author

Choose a reason for hiding this comment

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

FileName.combine() may or may not allocate memory, so it cannot be free'd.

Copy link
Member

Choose a reason for hiding this comment

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

So you mean we may leak? What FileName.free() does? It seems bad design if we leak resources.

@WalterBright WalterBright dismissed ljmf00’s stale review May 14, 2022 18:06

cannot free result of FileName.combine()

foreach (entry; (global.path ? (*global.path)[] : null))
{
auto f = FileName.combine(entry, "importc.h");
if (FileName.exists(f) == 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought this would be redundant, but it turns out exists returns a magic number

@WalterBright WalterBright merged commit bd30b13 into dlang:master May 14, 2022
@WalterBright WalterBright deleted the importc.h branch May 14, 2022 20:54
Comment on lines +703 to +704
error("cannot find \"importc.h\" along import path");
fatal();
Copy link
Member

Choose a reason for hiding this comment

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

:-(

@ibuclaw
Copy link
Member

ibuclaw commented May 17, 2022

Why is the burden placed on the callee of preprocess in order to find this header?

thewilsonator pushed a commit to thewilsonator/dmd that referenced this pull request May 26, 2022
thewilsonator pushed a commit to thewilsonator/dmd that referenced this pull request May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ImportC Pertaining to ImportC support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants