node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

error C2664 Cannot convert parameter 6 from 'const _Elem *' to 'PVOID'

Open beijing-penguin opened this issue 2 years ago • 5 comments

Node Version: v14.18.2 npm 6.14.15 Platform: window 10 x64 Module: node-gyp :v9.1.0 python:3.10.5

binding.gyp:

{
  "targets": [
    {
      "target_name": "addon",
      "sources": [ "addon.cc", "myobject.cc","shared.inl" ],
      "include_dirs": [
        "<!(node -e \"require('nan')\")",
		"./libyuv/include"
      ],
            "libraries": [

                "E:/vs_workspace/node_nan/node_nan/libyuv/build/Release/yuv.lib"
				
            ],
            "cflags": [
                "--std=c++11"
            ]
    }
  ]
}

run commond : node-gyp configure build

result:

E:\vs_workspace\node_nan\node_nan>node-gyp configure build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.10.5 found at "D:\Python\Python3105\python.exe"
gyp info find VS using VS2022 (17.2.32630.192) found at:
gyp info find VS "D:\Microsoft Visual Studio\2022\Community"
gyp info find VS run with --verbose for detailed information
gyp info spawn D:\Python\Python3105\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\DC-EMAR\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'E:\\vs_workspace\\node_nan\\node_nan\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\DC-EMAR\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\DC-EMAR\\AppData\\Local\\node-gyp\\Cache\\14.18.2\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\DC-EMAR\\AppData\\Local\\node-gyp\\Cache\\14.18.2',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\DC-EMAR\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\DC-EMAR\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\14.18.2\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=E:\\vs_workspace\\node_nan\\node_nan',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'E:\\vs_workspace\\node_nan\\node_nan\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn[0m D:\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m [
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m   'build/binding.sln',
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m   '/clp:Verbosity=minimal',
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m   '/nologo',
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m   '/p:Configuration=Release;Platform=x64'
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m ]
[0m在此解决方案中一次生成一个项目。若要启用并行生成,请添加“-m”开关。
  addon.cc
E:\vs_workspace\node_nan\node_nan\virtual_output.h(335,8): error C2664: “LSTATUS RegGetValueA(HKEY,LPCSTR,LPCSTR,DWORD,LPDWORD,PVOID,LPDWORD)”: 无法将参数 6 从“const _Elem *”转换为“PVOID” [E:\vs_workspace\node_nan\node_nan\build\addon.vcxproj]
          with
          [
              _Elem=char
          ]
E:\vs_workspace\node_nan\node_nan\virtual_output.h(335,81): message : 转换丢失限定符 [E:\vs_workspace\node_nan\node_nan\build\addon.vcxproj]
D:\Windows Kits\10\Include\10.0.19041.0\um\winreg.h(1266,1): message : 参见“RegGetValueA”的声明 [E:\vs_workspace\node_nan\node_nan\build\addon.vcxproj]
[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mbuild error[0m
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mstack[0m Error: `D:\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mstack[0m     at ChildProcess.onExit (C:\Users\DC-EMAR\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:201:23)
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mstack[0m     at ChildProcess.emit (events.js:400:28)
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mstack[0m     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mSystem[0m Windows_NT 10.0.19042
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mcommand[0m "D:\\nodejs\\node.exe" "C:\\Users\\DC-EMAR\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "build"
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mcwd[0m E:\vs_workspace\node_nan\node_nan
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mnode -v[0m v14.18.2
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mnode-gyp -v[0m v9.1.0
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mnot ok[0m
[0m

It is C++ compiler version problem? How do I change the c++ version?

Setting --std=c++11 or --std=c++20 is invalid

beijing-penguin avatar Aug 31 '22 07:08 beijing-penguin

~Does --msvs_version=2022 have any effect?~

cclauss avatar Aug 31 '22 08:08 cclauss

Does --msvs_version=2022 have any effect?

E:\vs_workspace\node_factory_wrap\node_factory_wrap>node-gyp configure --msvs_version=2022
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.10.5 found at "D:\Python\Python3105\python.exe"
gyp info find VS using VS2022 (17.2.32630.192) found at:
gyp info find VS "D:\Microsoft Visual Studio\2022\Community"
gyp info find VS run with --verbose for detailed information
gyp info spawn D:\Python\Python3105\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\DC-EMAR\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'E:\\vs_workspace\\node_factory_wrap\\node_factory_wrap\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\DC-EMAR\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\DC-EMAR\\AppData\\Local\\node-gyp\\Cache\\14.18.2\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\DC-EMAR\\AppData\\Local\\node-gyp\\Cache\\14.18.2',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\DC-EMAR\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\DC-EMAR\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\14.18.2\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=E:\\vs_workspace\\node_factory_wrap\\node_factory_wrap',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'E:\\vs_workspace\\node_factory_wrap\\node_factory_wrap\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
[37;40mgyp[0m [0m[32minfo[0m [0m[35mok[0m
[0m

==================rebuild=====

E:\vs_workspace\node_factory_wrap\node_factory_wrap>node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.10.5 found at "D:\Python\Python3105\python.exe"
gyp info find VS using VS2022 (17.2.32630.192) found at:
gyp info find VS "D:\Microsoft Visual Studio\2022\Community"
gyp info find VS run with --verbose for detailed information
gyp info spawn D:\Python\Python3105\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\DC-EMAR\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'E:\\vs_workspace\\node_factory_wrap\\node_factory_wrap\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\DC-EMAR\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\DC-EMAR\\AppData\\Local\\node-gyp\\Cache\\14.18.2\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\DC-EMAR\\AppData\\Local\\node-gyp\\Cache\\14.18.2',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\DC-EMAR\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\DC-EMAR\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\14.18.2\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=E:\\vs_workspace\\node_factory_wrap\\node_factory_wrap',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'E:\\vs_workspace\\node_factory_wrap\\node_factory_wrap\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn[0m D:\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m [
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m   'build/binding.sln',
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m   '/clp:Verbosity=minimal',
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m   '/nologo',
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m   '/p:Configuration=Release;Platform=x64'
[0m[37;40mgyp[0m [0m[32minfo[0m [0m[35mspawn args[0m ]
[0m在此解决方案中一次生成一个项目。若要启用并行生成,请添加“-m”开关。
  addon.cc
  myobject.cc
E:\vs_workspace\node_factory_wrap\node_factory_wrap\virtual_output.h(335,8): error C2664: “LSTATUS RegGetValueA(HKEY,LPCSTR,LPCSTR,DWORD,LPDWORD,PVOID,LPDWORD)”: 无法将参数 6 从“const _Elem *”转换为“PVOID” [E:\vs_workspace\node_factory_wrap\node_factory_wrap
\build\addon.vcxproj]
          with
          [
              _Elem=char
          ]
E:\vs_workspace\node_factory_wrap\node_factory_wrap\virtual_output.h(335,81): message : 转换丢失限定符 [E:\vs_workspace\node_factory_wrap\node_factory_wrap\build\addon.vcxproj]
D:\Windows Kits\10\Include\10.0.19041.0\um\winreg.h(1266,1): message : 参见“RegGetValueA”的声明 [E:\vs_workspace\node_factory_wrap\node_factory_wrap\build\addon.vcxproj]
E:\vs_workspace\node_factory_wrap\node_factory_wrap\myobject.cc(75,12): warning C4477: “printf”: 格式字符串“%d”需要类型“int”的参数,但可变参数 1 拥有了类型“size_t” [E:\vs_workspace\node_factory_wrap\node_factory_wrap\build\addon.vcxproj]
E:\vs_workspace\node_factory_wrap\node_factory_wrap\myobject.cc(75,12): message : 请考虑在格式字符串中使用“%zd” [E:\vs_workspace\node_factory_wrap\node_factory_wrap\build\addon.vcxproj]
[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mbuild error[0m
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mstack[0m Error: `D:\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mstack[0m     at ChildProcess.onExit (C:\Users\DC-EMAR\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:201:23)
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mstack[0m     at ChildProcess.emit (events.js:400:28)
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mstack[0m     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mSystem[0m Windows_NT 10.0.19042
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mcommand[0m "D:\\nodejs\\node.exe" "C:\\Users\\DC-EMAR\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mcwd[0m E:\vs_workspace\node_factory_wrap\node_factory_wrap
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mnode -v[0m v14.18.2
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mnode-gyp -v[0m v9.1.0
[0m[37;40mgyp[0m [0m[31;40mERR![0m [0m[35mnot ok[0m
[0m

beijing-penguin avatar Sep 02 '22 03:09 beijing-penguin

image

image

beijing-penguin avatar Sep 02 '22 03:09 beijing-penguin

@cclauss i have an important discovery....eg image: (PVOID)str.data() image

and run cmd : node-gyp configure rebuild is succeed compile

but I don't understand why my virtual_output.h file (before modification) can compile succeed with vs2022 , c++20 , when i use 'node-gyp configure rebuild ' is not ok.(i try binding.gyp set --std=c++20 or --msvs_version=2022 ,is all not ok)..

beijing-penguin avatar Sep 02 '22 04:09 beijing-penguin

At present, I don't know how to get node-gyp to compile in c++20

beijing-penguin avatar Sep 02 '22 04:09 beijing-penguin

This issue seems no longer relevant as it uses a no longer supported version of Node and has been stale for a long time. If there are no objections, I will close this issue next Mon-Tue. In case something similar happens again please open a new issue.

StefanStojanovic avatar Apr 18 '24 12:04 StefanStojanovic