From ac96911534431e1b597c18419cdff612bf2eabf1 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 19 Oct 2026 23:20:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=B0=86=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E7=BB=93=E6=9E=84=E4=BD=93=E7=94=B1?= =?UTF-8?q?=20typedef=20struct=20=E6=94=B9=E4=B8=BA=E5=85=B7=E5=90=8D=20st?= =?UTF-8?q?ruct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 MPU6500 与 heater 的初始化配置结构体改为 C++ 具名 struct 定义, 不再使用 `typedef struct {...} xxx_t` 的匿名写法,语义更清晰。 匿名结构体 + 默认成员初始化 + typedef的组合会触发 Clang 的 -Wnon-c-typedef-for-linkage --- boards/drivers/include/MPU6500.h | 6 +++--- boards/drivers/include/heater.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/boards/drivers/include/MPU6500.h b/boards/drivers/include/MPU6500.h index 9d90e8c6..15116838 100644 --- a/boards/drivers/include/MPU6500.h +++ b/boards/drivers/include/MPU6500.h @@ -144,13 +144,13 @@ namespace imu { - typedef struct { + struct mpu6500_init_t { bsp::SPIMaster* spi; bsp::GPIO* cs; bsp::GPIT* int_pin; bool use_mag = false; bool dma = true; - } mpu6500_init_t; + }; typedef void (*mpu6500_callback_t)(); @@ -225,4 +225,4 @@ namespace imu { static void callback_thread_func_(void* arg); }; -}; // namespace imu \ No newline at end of file +}; // namespace imu diff --git a/boards/drivers/include/heater.h b/boards/drivers/include/heater.h index a620d823..28e0957d 100644 --- a/boards/drivers/include/heater.h +++ b/boards/drivers/include/heater.h @@ -25,13 +25,13 @@ namespace driver { - typedef struct { + struct heater_init_t { bsp::PWM* pwm; float target_temp; float* pid_param = new float[3]{160, 0.1, 0}; float heater_I_limit = 300; float heater_output_limit = 500; - } heater_init_t; + }; class Heater { public: