From fbc0b9e5998cbcd0e0961d97c0c9d40e8707090d Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Mon, 7 Sep 2020 14:05:56 +0530 Subject: [PATCH] AP_UAVCAN: silence function cast warning/error for Registry template --- libraries/AP_UAVCAN/AP_UAVCAN.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/libraries/AP_UAVCAN/AP_UAVCAN.h b/libraries/AP_UAVCAN/AP_UAVCAN.h index 4698cf1c1c..256904fc3f 100644 --- a/libraries/AP_UAVCAN/AP_UAVCAN.h +++ b/libraries/AP_UAVCAN/AP_UAVCAN.h @@ -54,18 +54,31 @@ class TrafficReportCb; class ActuatorStatusCb; class ESCStatusCb; +#if defined(__GNUC__) && (__GNUC__ > 8) +#define DISABLE_W_CAST_FUNCTION_TYPE_PUSH \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wcast-function-type\"") +#define DISABLE_W_CAST_FUNCTION_TYPE_POP \ + _Pragma("GCC diagnostic pop") +#else +#define DISABLE_W_CAST_FUNCTION_TYPE_PUSH +#define DISABLE_W_CAST_FUNCTION_TYPE_POP +#endif + /* Frontend Backend-Registry Binder: Whenever a message of said DataType_ from new node is received, the Callback will invoke registery to register the node as separate backend. */ #define UC_REGISTRY_BINDER(ClassName_, DataType_) \ - class ClassName_ : public AP_UAVCAN::RegistryBinder { \ + class ClassName_ : public AP_UAVCAN::RegistryBinder { \ typedef void (*CN_Registry)(AP_UAVCAN*, uint8_t, const ClassName_&); \ - public: \ - ClassName_() : RegistryBinder() {} \ - ClassName_(AP_UAVCAN* uc, CN_Registry ffunc) : \ - RegistryBinder(uc, (Registry)ffunc) {} \ - } + public: \ + ClassName_() : RegistryBinder() {} \ + DISABLE_W_CAST_FUNCTION_TYPE_PUSH \ + ClassName_(AP_UAVCAN* uc, CN_Registry ffunc) : \ + RegistryBinder(uc, (Registry)ffunc) {} \ + DISABLE_W_CAST_FUNCTION_TYPE_POP \ + } class AP_UAVCAN : public AP_CANDriver { public: