【发布时间】: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
提前致谢:)
【问题讨论】:
-
Visual C++ 的预处理器定义应使用
/D命令行标志进行设置。 GYP 在defines部分允许这样做,请参阅gyp.gsrc.io/docs/UserDocumentation.md -
耶!有用。谢谢
标签: c++ node.js windows node-gyp node.js-addon