RobotWebTools / rclnodejs

Node.js version of ROS 2.0 client
https://docs.ros.org/en/humble/Concepts/Basic/About-Client-Libraries.html?highlight=rclnodejs#community-maintained
Apache License 2.0
312 stars 70 forks source link

GCC 8.x compiler warnings #779

Closed wayneparrott closed 3 years ago

wayneparrott commented 3 years ago

After updating to gcc8 I noticed 2 new compiler warnings:

  1. executor.cpp constructor initializes members in an order different from the order of the members in the class definition. This is easily resolved by reordering the member's initialization the constructor.
    In file included from ../src/executor.cpp:15:
    ../src/executor.hpp: In constructor ‘rclnodejs::Executor::Executor(rclnodejs::HandleManager*, rclnodejs::Executor::Delegate*)’:
    ../src/executor.hpp:71:18: warning: ‘rclnodejs::Executor::context_’ will be initialized after [-Wreorder]
    71 |   rcl_context_t* context_;
      |                  ^~~~~~~~
    ../src/executor.hpp:64:15: warning:   ‘uv_thread_t rclnodejs::Executor::main_thread_’ [-Wreorder]
    64 |   uv_thread_t main_thread_;
      |               ^~~~~~~~~~~~
    ../src/executor.cpp:44:1: warning:   when initialized here [-Wreorder]
    44 | Executor::Executor(HandleManager* handle_manager, Delegate* delegate)
      | ^~~~~~~~
  2. gcc8 added a cast-function-type warning that is being triggered from addon.cpp. I believe the warning is because of a parameter count mismatch in the definition of node::addon_register_func(), i.e., declares 2 params when only 1 is being passed. Because this warning is from node.h I'm not sure if there is a solution other than to squash it by using the compiler flags: -Wextra -Wno-cast-function-type. See GCC doc.
In file included from ../node_modules/nan/nan.h:56,
                 from ../src/addon.cpp:15:
/home/dev/.cache/node-gyp/12.18.0/include/node/node.h:608:43: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>)’ to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
  608 |       (node::addon_register_func) (regfunc),                          \
      |                                           ^
/home/dev/.cache/node-gyp/12.18.0/include/node/node.h:642:3: note: in expansion of macro ‘NODE_MODULE_X’
  642 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
      |   ^~~~~~~~~~~~~
../src/addon.cpp:94:1: note: in expansion of macro ‘NODE_MODULE’
   94 | NODE_MODULE(rclnodejs, InitModule);
      | ^~~~~~~~~~~