C/C++ Undefined Reference Problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

C/C++ Undefined Reference Problem

ソリューションへジャンプ
976件の閲覧回数
snricmn
Contributor II

Hi everyone,

I am not good at c/c++. I wanted to implement my own source codes (for example SPI with registers) so in the source folder of the project with main.c, I have mySPI.cpp and mySPI.h file. I added #include <mySPI.h> to main.c but it cannot see the functions.

If i call one of the function like SPI_Configure() from mySPI.cpp it says "undefined reference to SPI_Configure"

It is a simple question but i need help.

Thanks.

タグ(1)
1 解決策
577件の閲覧回数
snricmn
Contributor II

Hi Alice_Yang, thanks for help your way led me to the solutions. I needed to add cplusplus notation to your suggestion.

This below works:

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif

Thanks

Have a nice day

元の投稿で解決策を見る

0 件の賞賛
2 返答(返信)
577件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Ahmet,

Please add

extern "C"{ 

}
‍‍‍‍‍‍‍‍

into your mySPI.c file to have a try.

I also attached a project as your  said  , there is no error,  I use the KDS v3.2 .

Hope it helps


Have a great day,
Alice Yang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

578件の閲覧回数
snricmn
Contributor II

Hi Alice_Yang, thanks for help your way led me to the solutions. I needed to add cplusplus notation to your suggestion.

This below works:

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif

Thanks

Have a nice day

0 件の賞賛