node-addon-api
node-addon-api copied to clipboard
AsyncProgress*Worker does not support compile option -Woverloaded-virtual
Due to Execute() method overloaded in AsyncProgressWorker and AsyncProgressQueueWorker, projects using these classes and with -Woverloaded-virtual enabled will fail to compile.
Reproduction Apply the following and run tests.
diff --git a/common.gypi b/common.gypi
index 9be254f..17e78fb 100644
--- a/common.gypi
+++ b/common.gypi
@@ -17,5 +17,5 @@
],
'include_dirs': ["<!(node -p \"require('../').include_dir\")"],
'cflags': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ],
- 'cflags_cc': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ]
+ 'cflags_cc': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter', '-Woverloaded-virtual' ]
}
Workaround
Classes derived from AsyncProgressQueueWorker must add using AsyncWorker::Execute;. Diff for tests:
diff --git a/test/async_progress_queue_worker.cc b/test/async_progress_queue_worker.cc
index eec3f95..c3d4542 100644
--- a/test/async_progress_queue_worker.cc
+++ b/test/async_progress_queue_worker.cc
@@ -16,6 +16,7 @@ struct ProgressData {
};
class TestWorker : public AsyncProgressQueueWorker<ProgressData> {
+ using AsyncWorker::Execute;
public:
static Napi::Value CreateWork(const CallbackInfo& info) {
int32_t times = info[0].As<Number>().Int32Value();
diff --git a/test/async_progress_worker.cc b/test/async_progress_worker.cc
index 36087e7..f3ffbf5 100644
--- a/test/async_progress_worker.cc
+++ b/test/async_progress_worker.cc
@@ -16,6 +16,7 @@ struct ProgressData {
};
class TestWorker : public AsyncProgressWorker<ProgressData> {
+ using AsyncWorker::Execute;
public:
static void DoWork(const CallbackInfo& info) {
int32_t times = info[0].As<Number>().Int32Value();
@@ -66,6 +67,7 @@ class TestWorker : public AsyncProgressWorker<ProgressData> {
};
class MalignWorker : public AsyncProgressWorker<ProgressData> {
+ using AsyncWorker::Execute;
public:
static void DoWork(const CallbackInfo& info) {
Function cb = info[0].As<Function>();
Hi @jerylvaz,
Thanks for noticing this. Would you like to submit a PR...?
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
Hi @KevinEady, I don't think a fix is possible without breaking the API.
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.