Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用节点gyp编译时,CFLAGS在Windows上不工作_C++_Node.js_Windows_Node Gyp_Node.js Addon - Fatal编程技术网

C++ 使用节点gyp编译时,CFLAGS在Windows上不工作

C++ 使用节点gyp编译时,CFLAGS在Windows上不工作,c++,node.js,windows,node-gyp,node.js-addon,C++,Node.js,Windows,Node Gyp,Node.js Addon,由于某些原因,当我在Windows上使用节点gyp编译时,CFLAGS被忽略。有人知道原因吗?这是我的代码: Binding.gyp { "targets": [ { "target_name": "helloWindows", "sources": [ "helloWindows.cpp" ], "cflags": [ "-D_MY_FLAG"], } ] } helloWindows.cpp using namespace v8;

由于某些原因,当我在Windows上使用节点gyp编译时,CFLAGS被忽略。有人知道原因吗?这是我的代码:

Binding.gyp

{
  "targets": [
    {
      "target_name": "helloWindows",
      "sources": [ "helloWindows.cpp" ],
      "cflags": [ "-D_MY_FLAG"],
    }
  ]
}
helloWindows.cpp

using namespace v8;

#if defined(_MY_FLAG) 
void SuperFunction(const v8::FunctionCallbackInfo<Value>& args) {
  Isolate* isolate = Isolate::GetCurrent();
  HandleScope scope(isolate);

  args.GetReturnValue().Set(String::NewFromUtf8(isolate, "Hello Antirreni!"));

}

void init(Handle<Object> target) {
    NODE_SET_METHOD(target, "hello", SuperFunction);
}

NODE_MODULE(helloWindows, init);

#endif
使用名称空间v8;
#如果已定义(_MY_标志)
void超级函数(const v8::FunctionCallbackInfo&args){
隔离*隔离=隔离::GetCurrent();
手镜范围(隔离);
args.GetReturnValue().Set(字符串::NewFromUtf8(隔离“Hello Antirreni!”);
}
void init(句柄目标){
节点设置方法(目标,“你好”,超级函数);
}
节点_模块(helloWindows,init);
#恩迪夫
提前感谢:)

解决方法:

"defines":["_MY_FLAG"]
解决方法:

"defines":["_MY_FLAG"]

VisualC++的预处理器定义应该用<代码> /d < /COD>命令行标志来设置。GYP允许在
定义
部分进行此操作,请参见!它起作用了。VisualC++的HelpSpRever处理器定义应以<代码> /d < /代码>命令行标志设置。GYP允许在
定义
部分进行此操作,请参见!它起作用了。谢谢