'xxx' declared `static' but never defined

本文解析了在uart.c文件中定义的static函数delay,在uart.h中声明引发的编译警告,并提供了简单有效的解决方案。
部署运行你感兴趣的模型镜像

'xxx' declared `static' but never defined

【问题描述】

uart.c文件中有函数read_sample的实现:

static void delay(void)
{
       //statement
}
uart.h文件中有函数delay的声明:
static void delay(void);
程序编译的时候会报错:
warning: 'delay' defined but not never defined
【问题原因】
声明为static的函数不能被其他文件所使用,如果其他文件include uart.h。那么就会报上面的错误。
【解决办法】
解决的办法很简单,将头文件中的声明转移到.c文件中就可以了,即将函数delay的声明从uart.h移动到uart.c文件的开始就可以了。

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

conflicting types for 'getIntfNameAndDns'; have 'CMM_RET(LOAD_MULTI_CFG *, char *, size_t, char *, size_t, char *, size_t)' {aka 'CMM_RET(struct _LOAD_MULTI_CFG *, char *, long unsigned int, char *, long unsigned int, char *, long unsigned int)'} 2494 | static CMM_RET getIntfNameAndDns(LOAD_MULTI_CFG *pCfg, char interface[], size_t interfaceSize, | ^~~~~~~~~~~~~~~~~ src/tr143_load.c:137:16: note: previous declaration of 'getIntfNameAndDns' with type 'CMM_RET(char *, size_t, char *, size_t, char *, size_t)' {aka 'CMM_RET(char *, long unsigned int, char *, long unsigned int, char *, long unsigned int)'} 137 | static CMM_RET getIntfNameAndDns(char interface[], size_t interfaceSize, char intfName[], size_t intfNameSize, char dns[], size_t dnsSize); | ^~~~~~~~~~~~~~~~~ src/tr143_load.c: In function 'getIntfNameAndDns': src/tr143_load.c:2515:99: error: expected ')' before '{' token 2515 | sizeof(DEV2_IP_INTF_OBJ), &ipIntfStack, &ipIntfObj)) == CMM_OK) | ^ | ) 2516 | { | ~ src/tr143_load.c:2514:8: note: to match this '(' 2514 | if ((ret = RDP_WRAP(CMM_UI_INTERNAL, OID_DEV2, rsl_util_getObjFromFullpath(interface, OID_DEV2_IP_INTF, | ^ src/tr143_load.c:2514:5: note: '-Wmisleading-indentation' is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers 2514 | if ((ret = RDP_WRAP(CMM_UI_INTERNAL, OID_DEV2, rsl_util_getObjFromFullpath(interface, OID_DEV2_IP_INTF, | ^~ src/tr143_load.c:2514:5: note: adding '-flarge-source-files' will allow for more column-tracking support, at the expense of compilation time and memory src/tr143_load.c:3649:1: error: expected declaration or statement at end of input 3649 | } | ^ src/tr143_load.c:3649:1: error: no return statement in function returning non-void [-Werror=return-type] src/tr143_load.c: At top level: src/tr143_load.c:117:13: warning: 'loadParseIntfAndURL' declared 'static' but never defined [-Wunused-function] 117 | static BOOL loadParseIntfAndURL(LOAD_MULTI_CFG *pCfg, char *pDiagSt, size_t diagLen, char *pIntf, size_t intfLen, const char *loadURL); | ^~~~~~~~~~~~~~~~~~~ src/tr143_load.c:119:13: warning: 'loadInitCFG' declared 'static' but never defined [-Wunused-function] 119 | static BOOL loadInitCFG(LOAD_MULTI_CFG *pCfg, LOAD_PARAM_MSG *pParm, void *load_diag_obj); | ^~~~~~~~~~~ src/tr143_load.c:125:13: warning: 'loadCleanLastResult' declared 'static' but never defined [-Wunused-function] 125 | static BOOL loadCleanLastResult(LOAD_MULTI_CFG *pCfg, void *load_diag_obj, DM_NUM_STACK *stack); | ^~~~~~~~~~~~~~~~~~~ src/tr143_load.c:126:13: warning: 'loadInit_multi' declared 'static' but never defined [-Wunused-function] 126 | static BOOL loadInit_multi(LOAD_MULTI_DATA *pData, LOAD_PARAM_MSG *pLoadParam, char *pDiagSt, size_t diagLen); | ^~~~~~~~~~~~~~ src/tr143_load.c:2494:16: warning: 'getIntfNameAndDns' defined but not used [-Wunused-function] 2494 | static CMM_RET getIntfNameAndDns(LOAD_MULTI_CFG *pCfg, char interface[], size_t interfaceSize, | ^~~~~~~~~~~~~~~~~ src/tr143_load.c:2345:16: warning: 'tr143_getDefaultIntfName' defined but not used [-Wunused-function] 2345 | static CMM_RET tr143_getDefaultIntfName(LOAD_MULTI_CFG *pCfg, char *pIntf, size_t intfLen) | ^~~~~~~~~~~~~~~~~~~~~~~~ src/tr143_load.c:760:15: warning: 'tr143_getRecvBufLen' defined but not used [-Wunused-function] 760 | static UINT32 tr143_getRecvBufLen() | ^~~~~~~~~~~~~~~~~~~ src/tr143_load.c:733:15: warning: 'tr143_getSendBufLen' defined but not used [-Wunused-function] 733 | static UINT32 tr143_getSendBufLen() | ^~~~~~~~~~~~~~~~~~~ cc1: note: unrecognized command-line option '-Wno-unknown-warning-option' may have been intended to silence earlier diagnostics cc1: note: unrecognized command-line option '-Wno-pragma-pack' may have been intended to silence earlier diagnostics cc1: note: unrecognized command-line option '-Wno-parentheses-equality' may have been intended to silence earlier diagnostics cc1: note: unrecognized command-line option '-Wno-incompatible-function-pointer-types' may have been intended to silence earlier diagnostics cc1: all warnings being treated as errors Makefile:46: recipe for target 'tr143_load.o' failed make[2]: *** [tr143_load.o] Error 1 make[2]: Leaving directory '/home/bba/work/NB450/bba_3_0_platform/platform/apps/private/user/tr143' Makefile:1087: recipe for target 'tr143' failed make[1]: *** [tr143] Error 2 make[1]: Leaving directory '/home/bba/work/NB450/bba_3_0_platform/platform/apps/private/user' /home/bba/work/NB450/bba_3_0_platform/platform/build/makes/Makefile.apps.private:105: recipe for target 'cmm' failed make: *** [cmm] Error 2 quectel@38284d820af1:/home/bba/work/NB450/bba_3_0_platform/platform/build$ 报了那些错 给我总结一下。。
10-18
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值