ROBOTIS-GIT / Dynamixel2Arduino

DYNAMIXEL protocol library for Arduino
Apache License 2.0
88 stars 55 forks source link

Bug: Namespace clash in v0.7.0 #134

Open sseeberger96 opened 8 months ago

sseeberger96 commented 8 months ago

Hi! I recently upgraded a project of mine from v0.4.8 to v0.7.0 of this library and it broke my build. My compiler was complaining that a reference to 'Slave' is ambiguous , since another library I'm using also defines a Slave object. At first glance this error was odd to me, since the Dynamixel2Arduino slave class is nicely defined in its own namespace to avoid name clashes.

However, after digging a little deeper, I was able to isolate the problem to a specific update made in v0.7.0 (v0.6.3 does not cause me any issues). It looks like a using namespace DYNAMIXEL line was added to the protocol.h file here. Since this protocol.h file is included by utility/master.h which is included by Dynamixel2Arduino.h, any file that includes the Dynamixel2Arduino.h header is silently configured to use the DYNAMIXEL namespace.

This doesn't seem like intended behavior, since always using a namespace upon including a header basically defeats the purpose of having a namespace to begin with. So I'm hoping it's possible to make a patch here that removes the using namespace DYNAMIXEL line in protocol.h and just explicitly references the DYNAMIXEL namespace in the areas of protocol.h and protocol.cpp where it is needed.

Thanks!