Closed ethanjli closed 3 years ago
Once we fix this, we should also move the templated ==
and !=
operators in Application/States.h
into the Pufferfish::Application
namespace, so that those operators can only be found for classes/structs declared in Pufferfish::Application
.
Currently nanopb, as a C library, does not try to do anything with C++ namespaces when it declares the structs for the protobuf messages. This means that when we import
mcu_pb.h
in the firmware, it pollutes the global namespace with a bunch of declarations. Then when we need to define operator overloads for these structs (such as for the firmware's implementation of the Event Synchronization protocol), we have to declare those operator overloads in the global namespace too.Instead of polluting the global namespace this way, we should modify the
proto/generate_mcu.sh
script to add a line before line 12 to scope all the declarations inside a namespace (e.g.Pufferfish::Application
), and another one before line 270 to close that namespace scope. We could also instead try to close that namespace at the end of the file, but nanopb does declare ananopb
namespace for template specializations ofMessageDescriptor
so we'll have to check if that gets broken if we try to take that approach instead.While we're at it, we should also upgrade the files in
Core/Inc/nanopb
from 0.4.2 to 0.4.5, since we're now using nanopb generator 0.4.5 to generatemcu_pb.h
.