[英]IAR Error[Li005] : no definition for function even though the file is added in the project and the path to the file is in the pre-processor paths
I am having a strange problem.我有一个奇怪的问题。 I am trying to integrate the spi module from Nordic Semiconductors peripherals examples with the Central BLE Uart project.
我正在尝试将 Nordic Semiconductors 外设示例中的 spi 模块与 Central BLE Uart 项目集成。
There is a library of component common to all the examples.有一个所有示例通用的组件库。 So what I did is add the spi_slave file nrf_drv_spis.c to my project, and added the path to that component in the preprocessor paths of the project.
所以我所做的是将 spi_slave 文件nrf_drv_spis.c添加到我的项目中,并在项目的预处理器路径中添加该组件的路径。
$PROJ_DIR$\\..\\..\\..\\..\\..\\..\\..\\components\\drivers\\nrf_spi_slave
is in my preprocessor paths and this is where nrf_drv_spis.c and nrf_drv_spis.h are. $PROJ_DIR$\\..\\..\\..\\..\\..\\..\\..\\components\\drivers\\nrf_spi_slave
在我的预处理器路径中,这就是nrf_drv_spis.c和nrf_drv_spis.h 所在的位置。
However, when I compiled the code, I get this error但是,当我编译代码时,出现此错误
Error[Li005]: no definition for "nrf_drv_spis_init" [referenced from D:\Repo\ble_projects\nRF5_SDK_12.3.0\examples\ble_central\ble_app_uart_c\pca10028\s130\iar\_build\main.o]
nrf_drv_spis_init is a function found in nrf_drv_spis.c and the prototype is in nrf_drv_spis.h . nrf_drv_spis_init 是在nrf_drv_spis.c 中找到的函数,原型在nrf_drv_spis.h 中。 The odd thing as well is that when I right click on nrf_drv_spis_init and "go to the definition", it always bring me to the prototype in the header file.
奇怪的是,当我右键单击 nrf_drv_spis_init 并“转到定义”时,它总是将我带到头文件中的原型。 Normally, IAR presents me with either the prototype or the definition of the function and I need to click either the declaration or the prototype.
通常,IAR 向我显示函数的原型或定义,我需要单击声明或原型。
So it does shows me that for whatever reason, the file nrf_drv_spis.c doesn't seem to be in the project, but I don't know what to do to fix this.所以它确实告诉我,无论出于何种原因,文件nrf_drv_spis.c似乎不在项目中,但我不知道如何解决这个问题。
Any help would be appreciated.任何帮助,将不胜感激。 Thanks.
谢谢。
So the issue here is that I missed that in another crucial header file, some definitions were behind a #ifdef and thus when compiling the code, the right files weren't included.所以这里的问题是我在另一个关键的头文件中错过了这一点,一些定义在#ifdef 后面,因此在编译代码时,没有包含正确的文件。
Setting the right parameters made the code to compile correctly.设置正确的参数使代码能够正确编译。
I had the same issue, and the problem was global argument that I defined in the .h file (with extern).我遇到了同样的问题,问题是我在 .h 文件中定义的全局参数(使用 extern)。 When I moved them to the .c file it solved the problem.
当我将它们移动到 .c 文件时,它解决了问题。 I don't understand why, but it worked.
我不明白为什么,但它奏效了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.