这几天在看 Node.js 的官方文档,看到了 C++ 插件部分,由于很久没有接触 C/C++ 了,看起来着实吃力,决定写一个 Hello World 后跳过该部分。
在 Node.js 上使用 C++,需要用 node-gyp 工具对 C++ 文件进行编译,所以首先要安装 node-gyp :
npm install -g node-gyp
然后在项目目录下写一个 hello.cc 文件:
#include <node.h>
namespace demo{
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using