使用 node-gyp 编译时,CFLAGS 在 Windows 上不工作

CFLAGS not working on Windows when compiling with node-gyp

出于某种原因,当我在 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

提前致谢:)

解决方法:

"defines":["_MY_FLAG"]