gpt4 book ai didi

c - IAR 中的错​​误函数指针

转载 作者:行者123 更新时间:2023-11-30 21:05:17 29 4
gpt4 key购买 nike

我正在使用 IAR,但收到以下错误:

Error[Pe513]: a value of type "void *" cannot be assigned to an entity of type "void (*)(void)" 

下面是生成错误的代码:

uint32_t resethandler_adress = (volatile uint32_t)(FLASH_SECTOR2_BASE_ADRESSE + 4);

void (*app_reset_handler)(void);
app_reset_handler = (void*)resethandler_adress;

最佳答案

正如错误所述,void (*)(void)void* 不同。解决方案是将整数转换为适当的类型。这可以直接完成;目前尚不清楚为什么将其转换为uint32_t,然后转换为void* - 或者为什么您可能声明一个文字常量 volatile

typedef void (*tResetHandlerFn)(void);
tResetHandlerFn app_reset_handler = (tResetHandlerFn)(FLASH_SECTOR2_BASE_ADDRESS + 4) ;

关于c - IAR 中的错​​误函数指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55435607/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com