Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Fix Issue 19498 - undefined identifier rt_loadLibraryW #2414

Closed
wants to merge 2 commits into from

Conversation

edi33416
Copy link
Contributor

No description provided.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @edi33416! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
19498 regression undefined identifier rt_loadLibraryW

Testing this PR locally

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

dub fetch digger
dub run digger -- build "stable + druntime#2414"

@dlang-bot dlang-bot added the Bug Fix Include reference to corresponding bugzilla issue label Dec 20, 2018
@edi33416
Copy link
Contributor Author

@WalterBright

@@ -21,6 +21,8 @@ else version (WatchOS)

/// C interface for Runtime.loadLibrary
extern (C) void* rt_loadLibrary(const char* name);
/// ditto
version (Windows) extern (C) void* rt_loadLibrary(const WCHAR* name);
Copy link
Contributor

@kinke kinke Dec 20, 2018

Choose a reason for hiding this comment

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

Incompatible duplicate declarations for version (Windows) like this are rejected by LDC, and rightly so IMO. It also prevents a compile error when using the char 'overload' on Windows.

I don't think it's a good idea to have a C interface which diverges for Windows. The different param type isn't part of the mangled name, so you won't get linker errors, but ugly crashes for external (C[++]...) code using that interface (with the old const char* argument or in portable code which reasonably assumes this basic C interface is platform-independent).

Copy link
Contributor

Choose a reason for hiding this comment

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

@edi33416 per #2392 (review) that should be added back as rt_loadLibraryW that uses WCHAR*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thewilsonator I had the same fix in mind, but please see @WalterBright comments on the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't move the core.runtime.loadLibrary() implementation to rt.dmain2.rt_loadLibrary(), as rt_loadLibrary() takes a const char* instead of const char[], so it's losing the length information (unless it's safe to call strlen(name) )

buf[len] = '\0';

return rt_loadLibraryW(buf);
name[$ - 1] = '\0';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this actually tested? Given in char[] name I would expect mutation to fail.

Copy link
Member

@rainers rainers Dec 26, 2018

Choose a reason for hiding this comment

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

Yes, fails to compile. If it would, it removes the last character. Time to add a test similar to test/uuid?

@rainers
Copy link
Member

rainers commented Dec 26, 2018

Pedantically, this and #2392 are breaking changes:

  • rt_loadLibraryW was a public symbol before
  • rt_loadLibrary now assumes a different encoding (UTF8 instead of ANSI)

@rainers
Copy link
Member

rainers commented Dec 29, 2018

My suggestion: just restore the declaration for now: #2425
A fix towards UTF8 aware rt_loadLibrary can come later...

@PetarKirov
Copy link
Member

#2425 was merged -> closing.

@PetarKirov PetarKirov closed this Dec 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Fix Include reference to corresponding bugzilla issue
Projects
None yet
6 participants