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

urandom: fix for Nim 2.0 by using only CryptAcquireContextW #9

Closed
wants to merge 1 commit into from

Conversation

ee7
Copy link
Contributor

@ee7 ee7 commented Aug 6, 2023

Before this commit, compiling urandom.nim on Windows with Nim 2.0 would produce an error:

$ nim c --os:windows uuids/urandom.nim
/foo/pragmagic-uuids/uuids/urandom.nim(15, 8) Error: undeclared identifier: 'useWinUnicode'

This was because Nim 2.0 removed the useWinUnicode identifier.

Fix by always using CryptAcquireContextW on Windows.

Fixes: #8


I don't have a Windows machine to test this on. This PR may not be sufficient to make the uuids package work with Nim 2.0 on Windows.

Before this commit, compiling urandom.nim on Windows with Nim 2.0 would
produce an error:

    $ nim c --os:windows uuids/urandom.nim
    /foo/pragmagic-uuids/uuids/urandom.nim(15, 8) Error: undeclared identifier: 'useWinUnicode'

This was because Nim 2.0 [1] removed the useWinUnicode identifier [2].

Fix by always using CryptAcquireContextW on Windows.

Fixes: pragmagic#8

[1] https://nim-lang.org/blog/2023/08/01/nim-v20-released.html
[2] nim-lang/Nim@612abda
@endragor
Copy link
Member

endragor commented Aug 6, 2023

Thanks for the PR! Can you make the change backward-compatible please? So that useWinUnicode is checked on Nim 1.x, but not on Nim 2.x.

@endragor endragor closed this Dec 14, 2023
@ee7 ee7 deleted the urandom-CryptAcquireContext branch December 15, 2023 10:35
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.

urandom: compile error on Windows with Nim 2.0
2 participants