使用node-gyp进行编译时,CFLAGS无法在Windows上运行

时间:2015-11-20 14:03:46

标签: c++ node.js windows node-gyp node.js-addon

由于某种原因,当我在Windows上使用node-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

提前致谢:)

1 个答案:

答案 0 :(得分:0)

解决:

"defines":["_MY_FLAG"]