NUbots / NUWebots

Environment, models, and communication for using the Webots simulation with NUbots
MIT License
7 stars 4 forks source link

Add more compiler warnings and function for setting them #46

Closed KipHamiltons closed 3 years ago

KipHamiltons commented 3 years ago

I found a really nice comprehensive list of compiler warnings and a script/function to add them. This adds them for this codebase.

should I do something similar for NUbots?

KipHamiltons commented 3 years ago

this introduces just one compiler warning from protobuf, and I can't work out how to remove it haha

[1/3] Building CXX object controllers/nugus_controller/CMakeFiles/robot_control_protobuf.dir/protobuf/RobotControl.pb.cc.o
controllers/nugus_controller/protobuf/RobotControl.pb.cc: In member function ‘virtual const char* controller::nugus::RobotControl::_InternalParse(const char*, google::protobuf::internal::ParseContext*’:
controllers/nugus_controller/protobuf/RobotControl.pb.cc:98:65: warning: conversion from ‘google::protobuf::uint64’ {aka ‘long unsigned int’} to ‘google::protobuf::int32’ {aka ‘int’} may change value -Wconversion]
   98 |           num_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
TrentHouliston commented 3 years ago

The way I delt with all the warnings in the generated code is I didn't have any warnings when compiling those files (I made them a separate library)

Bidski commented 3 years ago

this introduces just one compiler warning from protobuf, and I can't work out how to remove it haha

[1/3] Building CXX object controllers/nugus_controller/CMakeFiles/robot_control_protobuf.dir/protobuf/RobotControl.pb.cc.o
controllers/nugus_controller/protobuf/RobotControl.pb.cc: In member function ‘virtual const char* controller::nugus::RobotControl::_InternalParse(const char*, google::protobuf::internal::ParseContext*’:
controllers/nugus_controller/protobuf/RobotControl.pb.cc:98:65: warning: conversion from ‘google::protobuf::uint64’ {aka ‘long unsigned int’} to ‘google::protobuf::int32’ {aka ‘int’} may change value -Wconversion]
   98 |           num_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);

I had to disable a number of warnings on the generated protobuf files in the nubots codebase (probably in nuclear roles neutrons)

TrentHouliston commented 3 years ago

Yeah, one of the things that I did in the cmake modernise stuff is to move protobufs into their own nonsense land with no warnings so that NUbots doesn't disable all those warnings in the actual codebase