由于某种原因,当我在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
提前致谢:)
答案 0 :(得分:0)
解决:
"defines":["_MY_FLAG"]