The return type is incompatible with ***Service.***(****)

本文讲述了在编程中遇到的方法签名冲突问题,特别是在实现service接口时,私有方法与接口中的方法重名导致的编译错误。通过更改方法名称,成功解决了这一问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The return type is incompatible with CustomerInfoService.updateCubeCAndCubeCEByCustomer(CustomerInfo)
方法写完了正准备测试却发现方法void处报红叉,鼠标移上去显示这个错误,翻译如下:
谷歌翻译
在这里插入图片描述
检查好久最后发现是service实现层的这个私有方法与service接口中的方法重名了……
解决办法:2选一改方法名即可。

*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' Build target 'Can_Serial' compiling outctl_task.c... ..\TASK\outctl_task.c(35): error: #101: "osOK" has already been declared in the current scope osOK = 0, ///< function completed; no error or event occurred. ..\TASK\outctl_task.c(36): error: #101: "osEventSignal" has already been declared in the current scope osEventSignal = 0x08, ///< function completed; signal event occurred. ..\TASK\outctl_task.c(37): error: #101: "osEventMessage" has already been declared in the current scope osEventMessage = 0x10, ///< function completed; message event occurred. ..\TASK\outctl_task.c(38): error: #101: "osEventMail" has already been declared in the current scope osEventMail = 0x20, ///< function completed; mail event occurred. ..\TASK\outctl_task.c(39): error: #101: "osEventTimeout" has already been declared in the current scope osEventTimeout = 0x40, ///< function completed; timeout occurred. ..\TASK\outctl_task.c(40): error: #101: "osErrorParameter" has already been declared in the current scope osErrorParameter = 0x80, ///< parameter error: a mandatory parameter was missing or specified an incorrect object. ..\TASK\outctl_task.c(41): error: #101: "osErrorResource" has already been declared in the current scope osErrorResource = 0x81, ///< resource not available: a specified resource was not available. ..\TASK\outctl_task.c(42): error: #101: "osErrorTimeoutResource" has already been declared in the current scope osErrorTimeoutResource = 0xC1, ///< resource not available within given time: a specified resource was not available within the timeout period. ..\TASK\outctl_task.c(43): error: #101: "osErrorISR" has already been declared in the current scope osErrorISR = 0x82, ///< not allowed in ISR context: the function cannot be called from interrupt service routines. ..\TASK\outctl_task.c(44): error: #101: "osErrorISRRecursive" has already been declared in the current scope osErrorISRRecursive = 0x83, ///< function called multiple times from ISR with same object. ..\TASK\outctl_task.c(45): error: #101: "osErrorPriority" has already been declared in the current scope osErrorPriority = 0x84, ///< system cannot determine priority or thread has illegal priority. ..\TASK\outctl_task.c(46): error: #101: "osErrorNoMemory" has already been declared in the current scope osErrorNoMemory = 0x85, ///< system is out of memory: it was impossible to allocate or reserve memory for the operation. ..\TASK\outctl_task.c(47): error: #101: "osErrorValue" has already been declared in the current scope osErrorValue = 0x86, ///< value of a parameter is out of range. ..\TASK\outctl_task.c(48): error: #101: "osErrorOS" has already been declared in the current scope osErrorOS = 0xFF, ///< unspecified RTOS error: run-time error but no other error message fits. ..\TASK\outctl_task.c(49): error: #101: "os_status_reserved" has already been declared in the current scope os_status_reserved = 0x7FFFFFFF ///< prevent from enum down-size compiler optimization. ..\TASK\outctl_task.c(50): error: #256: invalid redeclaration of type name "osStatus" (declared at line 205 of "../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.h") } osStatus; ..\TASK\outctl_task.c(52): error: #147-D: declaration is incompatible with "osStatus osDelay(uint32_t)" (declared at line 478 of "../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.h") osStatus osDelay (uint32_t millisec); ..\TASK\outctl_task.c: 0 warnings, 17 errors "Can_Serial\Can_Serial.axf" - 17 Error(s), 0 Warning(s). Target not created. Build Time Elapsed: 00:00:02”“/** ****************************(C) COPYRIGHT 2021 DIODE**************************** * @file led_task.c/h * @brief led task, * led灯任务 * @note * @history * Version Date Author Modification * @verbatim ============================================================================== ============================================================================== @endverbatim ****************************(C) COPYRIGHT 2021 DIODE**************************** */ #include "outctl_task.h" #include "struct_typedef.h" // 正确顺序(CMSIS-RTOS必须在FreeRTOS之后) #include "FreeRTOS.h" // 必须最先包含 #include "task.h" // FreeRTOS核心 #include "cmsis_os.h" // CMSIS封装层 extern uint16_t RC_FLAG; uint16_t time_crl; uint8_t rc_flag=0,rc_out_time=20; //num记录离线时间 uint8_t vision_flag=0,vision_out_time=20; //num记录离线时间 bool_t rc_unable_flag=0; uint8_t sw2; extern uint8_t CAN_M3508_Cnt[]; extern uint8_t CAN_M3508_Flag[]; typedef enum { osOK = 0, ///< function completed; no error or event occurred. osEventSignal = 0x08, ///< function completed; signal event occurred. osEventMessage = 0x10, ///< function completed; message event occurred. osEventMail = 0x20, ///< function completed; mail event occurred. osEventTimeout = 0x40, ///< function completed; timeout occurred. osErrorParameter = 0x80, ///< parameter error: a mandatory parameter was missing or specified an incorrect object. osErrorResource = 0x81, ///< resource not available: a specified resource was not available. osErrorTimeoutResource = 0xC1, ///< resource not available within given time: a specified resource was not available within the timeout period. osErrorISR = 0x82, ///< not allowed in ISR context: the function cannot be called from interrupt service routines. osErrorISRRecursive = 0x83, ///< function called multiple times from ISR with same object. osErrorPriority = 0x84, ///< system cannot determine priority or thread has illegal priority. osErrorNoMemory = 0x85, ///< system is out of memory: it was impossible to allocate or reserve memory for the operation. osErrorValue = 0x86, ///< value of a parameter is out of range. osErrorOS = 0xFF, ///< unspecified RTOS error: run-time error but no other error message fits. os_status_reserved = 0x7FFFFFFF ///< prevent from enum down-size compiler optimization. } osStatus; osStatus osDelay (uint32_t millisec); //控制模式 eRemoteMode remoteMode = RC; eSystemState systemState = SYSTEM_STARTING; //系统状态 osStatus osDelay (uint32_t millisec) { #if INCLUDE_vTaskDelay TickType_t ticks = millisec / portTICK_PERIOD_MS; vTaskDelay(ticks ? ticks : 1); /* Minimum delay = 1 tick */ return osOK; #else (void) millisec; return osErrorResource; #endif } /** * @brief 失控保护任务,间隔 OUTCTL_TASK_TIME_MS 100ms * @param[in] pvParameters: 空 * @retval none */ void outctl_task(void const *pvParameters) { //空闲一段时间 osDelay(OUTCTL_TASK_INIT_TIME); // uint8_t i=0; while (1) { time_crl++; rc_out_time++; vision_out_time++; CAN_M3508_Cnt[0]++; CAN_M3508_Cnt[1]++; CAN_M3508_Cnt[2]++; CAN_M3508_Cnt[3]++; if(rc_out_time>20) rc_out_time=20; if(rc_out_time>10) rc_flag=0; else rc_flag=1; // for(i=0;i<4;i++) // { // if(CAN_M3508_Cnt[i]>20) // CAN_M3508_Cnt[i]=20; // if(CAN_M3508_Cnt[i]>10) // CAN_M3508_Flag[i]=1; // else CAN_M3508_Flag[i]=0; // client_state_now.CAN_M3508_Flag[i]= CAN_M3508_Flag[i]; // } //系统相对延时 osDelay(OUTCTL_TASK_TIME_MS); } } void RC_unable(void){ rc_unable_flag=1; } void RC_restart(void){ rc_unable_flag=0; } /** * @brief 拨杆模式选择 * @param void * @retval void * @attention 键盘或鼠标,可在此自定义模式选择方式,1ms执行一次 */ //void SYSTEM_UpdateRemoteMode( void ) //{ // if (rc.sw2==1 || rc.sw2==3) // { // remoteMode = RC; // } // else // { // remoteMode = PC; // } //} //返回控制模式 eRemoteMode SYSTEM_GetRemoteMode(void) { return remoteMode; } //返回系统状态 eSystemState SYSTEM_GetSystemState(void) { return systemState; } ”现在错误更多了
最新发布
06-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值