Skip to content

Fix for MSVC 2022, node 22, on Windows to use more specific declarations+casts. #281

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

Open
kmashint opened this issue Apr 18, 2025 · 0 comments

Comments

@kmashint
Copy link
Contributor

kmashint commented Apr 18, 2025

See PR #280
Fix for MSVC 2022, node 22, on Windows to use more specific declarations+casts.

With node@22 and MS VisualStudio 2022 BuildTools on Windows 10, the registry-js package was failing to build via node-gyp.
I had to upgrade to at least node-gyp@9 (latest node-gyp@11) for it to recognize VisualStudio 2022, and then there were build errors with main.cc that after some investigation appeared to need stricter declaration/casting. I've attempted a reasonable fix based on the errors although I'm not a C/C++ expert. This now npm installs, builds, and npm run test is successful.

  main.cc
\registry-js\src\main.cc(128,20): error C2665: '`anonymous-namespace'::CreateEntry': no overloaded function coul
d convert all the argument types [\registry-js\build\registry.vcxproj]
      \registry-js\src\main.cc(45,14):
      could be 'Napi::Object `anonymous-namespace'::CreateEntry(Napi::Env &,LPWSTR,LPWSTR,LPWSTR,DWORD)'
          \registry-js\src\main.cc(128,20):
          'Napi::Object `anonymous-namespace'::CreateEntry(Napi::Env &,LPWSTR,LPWSTR,LPWSTR,DWORD)': cannot convert arg
  ument 3 from 'const wchar_t [7]' to 'LPWSTR'
              \registry-js\src\main.cc(128,47):
              Conversion from string literal loses const qualifier (see /Zc:strictStrings)
      \registry-js\src\main.cc(128,20):
      while trying to match the argument list '(Napi::Env, WCHAR [16383], const wchar_t [7], LPWSTR, DWORD)'

\registry-js\src\main.cc(134,20): error C2665: '`anonymous-namespace'::CreateEntry': no overloaded function coul
d convert all the argument types [\registry-js\build\registry.vcxproj]
      \registry-js\src\main.cc(45,14):
      could be 'Napi::Object `anonymous-namespace'::CreateEntry(Napi::Env &,LPWSTR,LPWSTR,LPWSTR,DWORD)'
          \registry-js\src\main.cc(134,20):
          'Napi::Object `anonymous-namespace'::CreateEntry(Napi::Env &,LPWSTR,LPWSTR,LPWSTR,DWORD)': cannot convert arg
  ument 3 from 'const wchar_t [14]' to 'LPWSTR'
              \registry-js\src\main.cc(134,47):
              Conversion from string literal loses const qualifier (see /Zc:strictStrings)
      \registry-js\src\main.cc(134,20):
      while trying to match the argument list '(Napi::Env, WCHAR [16383], const wchar_t [14], LPWSTR, DWORD)'
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