0
由于某些原因,当我在Windows上使用node-gyp进行编译时,CFLAGS被忽略。有人可能知道原因吗?这是我的代码:使用node-gyp进行编译时,CFLAGS无法在Windows上运行
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允许在'define'部分使用这个,参见https://gyp.gsrc.io/docs/UserDocumentation.md – pmed
Yay!有用。谢谢 – Antirreni91