nodejs / node-addon-api

Module for using Node-API from C++
MIT License
2.15k stars 460 forks source link

How do I initialize a variable of type napi_value to NULL to avoid compiler warnings #1477

Closed sharadraju closed 4 months ago

sharadraju commented 5 months ago

We use node-addon-api code for our Node.js driver (oracledb) for Oracle Database.

We are facing some compiler warnings for uninitialized napi_value type variable. Can I initialize a variable of type napi_value to NULL?

KevinEady commented 5 months ago

You should just be able to napi_value foo = nullptr; but nullptr is not a valid value (ie. it is not the same as JavaScript null) so do not pass this nullptr to Node-API functions.

sharadraju commented 5 months ago

Thanks @KevinEady. Let me try that

KevinEady commented 4 months ago

Closing due to inactivity. Let us know if you need more help.

sharadraju commented 4 months ago

Yes, we found the solution for this. Thanks @KevinEady for helping.