【问题标题】:CFLAGS not working on Windows when compiling with node-gyp使用 node-gyp 编译时 CFLAGS 在 Windows 上不起作用
【发布时间】:2015-11-20 14:03:45
【问题描述】:

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

提前致谢:)

【问题讨论】:

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


【解决方案1】:

解决方法:

"defines":["_MY_FLAG"]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-09
    • 1970-01-01
    • 2021-02-07
    • 2020-12-15
    • 2021-12-17
    • 2020-05-04
    • 2014-02-07
    相关资源
    最近更新 更多