Comments (12)
Also, all the other node-addon-api
exports can be added unconditionally to either the "include_dirs"
or "dependencies"
of a dependent target, because the conditionality is encapsulated in index.js
.
from node-addon-api.
I guess it doesn't really cost that much to keep .isNodeApiBuiltin
so we export something that can be used as a condition statement for unforeseen use cases, but we should definitely have the .defines
in addition.
from node-addon-api.
The .isNodeApiBuiltin
export was meant to be exposed as a runtime flag in case anybody wanted to write code to check that. But it's not used anywhere today, and there should be no need to use it at build time.
Did you follow the instructions in the README? You shouldn't need to define EXTERNAL_NAPI
anywhere in your module's node.gyp
. That is taken care of by these two lines to be added to your node.gyp
:
'include_dirs': ["<!(node -p \"require('node-addon-api').include\")"],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
Then when you #include "napi.h"
that should get src/napi.h
that has #define EXTERNAL_NAPI
at the top.
from node-addon-api.
I don't use the C++ API.
from node-addon-api.
https://github.com/gabrielschulhof/iotivity-node/blob/node-addon-api/binding.gyp#L221-L232
from node-addon-api.
OK, I guess I can include napi.h
directly, because I'm doing C++ anyway.
from node-addon-api.
I can't use napi.h because that requires exception handling to be enabled, which, for the plain C API I don't need.
from node-addon-api.
Hmm... using only the C APIs via this package wasn't a scenario I considered.
from node-addon-api.
Well, adding .defines
and a mention in the README.md
should cover plain C.
from node-addon-api.
Yes that will work. I had wanted to minimize the amount of stuff you have to add to your .gyp
file. But one more line won't hurt.
from node-addon-api.
Although perhaps you could do the path juggling as you do now, but instead of including napi.h
after defining EXTERNAL_NAPI, you include node_api.h
.
from node-addon-api.
... and then, when napi.h includes node_api.h, it will receive it from the appropriate directory.
from node-addon-api.
Related Issues (20)
- Consume async JS function by TypedThreadSafeFunction ? HOT 4
- Obtain JavaScript function name from Napi::Function instance ? HOT 2
- idea: detect JS calls at compile time HOT 4
- Instantiation of ObjectWrap in c++ code causes crash HOT 3
- Just a simple question. HOT 2
- Enabling C++ exceptions on Windows is hell HOT 2
- New SemVer Major release? HOT 4
- Getting sigsegv when passing functions as parameters and building on M1 HOT 4
- Are native addons affected by Node's max memory size constraint? HOT 2
- Running single AsyncWorker at a time HOT 3
- <doc/setup.md> seems outdated HOT 1
- Query on reading/writing js typed arrays from C module. HOT 2
- Request a c++ call js demo. HOT 3
- How to properly handle `Object/Buffer/Uint8Array` in `AsyncWorker`? HOT 9
- How about add C++20 coroutine support to `Napi::Value`? HOT 9
- Node throws exception in main thread (?) when trying to execute event via ThreadSafeFunction HOT 2
- Throwing an object as an exception? HOT 3
- Napi::Value is not properly initialized the first time a program is run HOT 22
- Strange behavior HOT 2
- How do I initialize a variable of type napi_value to NULL to avoid compiler warnings HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-addon-api.