ROBOTIS-GIT / dynamixel-workbench

ROS packages for Dynamixel controllers, msgs, single_manager, toolbox, tutorials
http://emanual.robotis.com/docs/en/software/dynamixel/dynamixel_workbench/
Apache License 2.0
107 stars 174 forks source link

fix variable length warning using std::vector #363

Closed ijnek closed 2 years ago

ijnek commented 2 years ago

Resolves: https://github.com/ROBOTIS-GIT/DynamixelSDK/issues/553

Gets rid of the following warning:

Starting >>> dynamixel_workbench_toolbox
--- stderr: dynamixel_workbench_toolbox                              
/home/ijnek/tmp_workspaces/dynamixel_control_ws/src/dynamixel-workbench/dynamixel_workbench_toolbox/src/dynamixel_workbench_toolbox/dynamixel_driver.cpp: In member function ‘bool DynamixelDriver::readRegister(uint8_t, uint16_t, uint16_t, uint32_t*, const char**)’:
/home/ijnek/tmp_workspaces/dynamixel_control_ws/src/dynamixel-workbench/dynamixel_workbench_toolbox/src/dynamixel_workbench_toolbox/dynamixel_driver.cpp:776:11: warning: ISO C++ forbids variable length array ‘data_read’ [-Wvla]
  776 |   uint8_t data_read[length];
      |           ^~~~~~~~~
/home/ijnek/tmp_workspaces/dynamixel_control_ws/src/dynamixel-workbench/dynamixel_workbench_toolbox/src/dynamixel_workbench_toolbox/dynamixel_driver.cpp: In member function ‘bool DynamixelDriver::syncWrite(uint8_t, uint8_t*, uint8_t, int32_t*, uint8_t, const char**)’:
/home/ijnek/tmp_workspaces/dynamixel_control_ws/src/dynamixel-workbench/dynamixel_workbench_toolbox/src/dynamixel_workbench_toolbox/dynamixel_driver.cpp:1012:11: warning: ISO C++ forbids variable length array ‘multi_parameter’ [-Wvla]
 1012 |   uint8_t multi_parameter[4*data_num_for_each_id];
      |           ^~~~~~~~~~~~~~~
---
sven-hoek commented 2 years ago

Haven't checked this out to build and test it but seems to be exactly what I did and it worked for me. Thanks for making a pull request (btw, you could have committed these changes onto the branch of the other PR you made and wouldn't have needed to delete it, but this way it's also fine) Also: the #include <memory> isn't necessary here anymore but a #include <vector> instead (or rather best/good practice than necessary).

ijnek commented 2 years ago

Oops, accidentally closed as a result of a branch rename. As Github doesn't let me re-open this PR, I'm going to open another one (#364)