繁体   English   中英

使用#ifndef中断node-gyp模块

[英]Using #ifndef breaks node-gyp module

我正在使用C++node-gyp编写一个node.js模块,但是当我修复所有错误时,例如在问题中,该错误包括通过添加来消除多余的声明

#ifndef BUILDING_NODE_EXTENSION

#endif  

到我的文件。 然后我得到了错误

module.js:356
  Module._extensions[extension](this, filename);
                               ^
Error: Symbol graph_module not found.
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/home/project/test.js:1:75)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

但是当我删除它们时,一切正常,相反,我只是得到了编译器警告,例如

  CXX(target) Release/obj.target/graph/graph/addon.o
../graph/addon.cc:2:9: warning: 'BUILDING_NODE_EXTENSION' macro redefined
#define BUILDING_NODE_EXTENSION

我不明白为什么会这样,并且我想尽可能摆脱编译器警告。 有什么想法吗?

看起来您已经忘记使用NODE_MODULE宏,或者绑定中模块的名称。gyp与NODE_MODULE中使用的模块不匹配

要摆脱编译器警告,请尝试替换

#define BUILDING_NODE_EXTENSION

#define BUILDING_NODE_EXTENSION 1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM