我在nodejs中是新手,并且在我的项目中运行class Store
{
private:
int value;
public:
__declspec(dllexport) void Put(int value)
{
this->value = value;
}
__declspec(dllexport) int Get()
{
return this->value;
}
__declspec(dllexport) void Increment()
{
this->value++;
}
};
extern "C"
{
__declspec(dllexport) int PlusOne(int x)
{
return x + 1;
}
__declspec(dllexport) Store* NewStore()
{
return new Store;
}
__declspec(dllexport) void DeleteStore(Store* store)
{
delete store;
}
}
class Program
{
[DllImport("CplusPlusSide.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int PlusOne(int x);
[DllImport("CplusPlusSide.dll", CallingConvention = CallingConvention.Cdecl)]
extern static IntPtr NewStore();
[DllImport("CplusPlusSide.dll", CallingConvention = CallingConvention.Cdecl)]
extern static void DeleteStore(IntPtr store);
// EntryPoint generated with DUMPBIN /exports dllname.dll
[DllImport("CplusPlusSide.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?Put@Store@@QAEXH@Z")]
extern static void Put32(IntPtr store, int value);
// EntryPoint generated with DUMPBIN /exports dllname.dll
[DllImport("CplusPlusSide.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?Get@Store@@QAEHXZ")]
extern static int Get32(IntPtr store);
// EntryPoint generated with DUMPBIN /exports dllname.dll
[DllImport("CplusPlusSide.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?Increment@Store@@QAEXXZ")]
extern static void Increment32(IntPtr store);
// EntryPoint generated with DUMPBIN /exports dllname.dll
[DllImport("CplusPlusSide.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?Put@Store@@QEAAXH@Z")]
extern static void Put64(IntPtr store, int value);
// EntryPoint generated with DUMPBIN /exports dllname.dll
[DllImport("CplusPlusSide.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?Get@Store@@QEAAHXZ")]
extern static int Get64(IntPtr store);
// EntryPoint generated with DUMPBIN /exports dllname.dll
[DllImport("CplusPlusSide.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?Increment@Store@@QEAAXXZ")]
extern static void Increment64(IntPtr store);
static void Main(string[] args)
{
int x = PlusOne(1);
Console.WriteLine(x);
IntPtr store = NewStore();
int ret;
if (IntPtr.Size == 8)
{
Put64(store, 5);
Increment64(store);
ret = Get64(store);
}
else
{
Put32(store, 5);
Increment32(store);
ret = Get32(store);
}
Console.WriteLine(ret);
DeleteStore(store);
}
}
时出错。
npm install
我不知道这个错误:npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "i"
npm ERR! node v7.7.1
npm ERR! npm v4.1.2
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents@1.0.15: wanted {"os":"darwin",
"arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64
npm ERR! Please include the following file with any support request:
npm ERR! C:\projects\rehouse\src\dd_rehouse_renewal_win\npm-debug.log
请帮我解决一下。
答案 0 :(得分:0)
从this讨论开始,我会首先尝试接近1。如果这不起作用,请尝试接近2.
添加:
"optionalDependencies": {
"fsevents": "*"
},
到您的package.json,然后使用--no-optional
尝试将您的npm版本降级到下一个稳定版本。