2019-07-18 07:24 AM
I have declared a typedef struct data_t on my jsmn.h
after that I declared a variable DATA of type data_t on jsmn.c
and i defined N,T,C and H
then i declared DATA of type Data_t as extern on ScreenViewBase.cpp
and i try to display DATA.N on the screen
but a linker error appear : no definition for DATA referenced from ScreenViewBase.o
PS1: I do the same with time : in ScreenViewBase.cpp I declared extern RTC_TimeTypeDef sTime then I write Unicode::snprintf(Ndata, 6, "%02d",sTime.Hours ); and it work perfectly.
PS2: I work with stm32f769 and with IAR 8.32.3
2019-07-18 07:41 AM
Perhaps because DATA isn't very original, and is used as a variable or section name within the namespace of the project, or associated libraries.
Pick something more unique...
2019-07-18 07:48 AM
Hi @Community member
I tried that(I replaced with youssef_data) but steel the same problem
2019-07-18 07:56 AM
Are we sure this is a linker error?
Post a build log, saves playing guess what's wrong.
2019-07-18 08:01 AM
this is a screenshot of the build log
2019-07-18 08:10 AM
Kind of suggests
a) jsmn.c isn't in the project
b) The mixing of C/CPP compilation results in name mangling on the C++ side, and thus an inability to find the symbol
Perhaps use
extern "C" Data_t DATA;
2019-07-18 08:16 AM
a) jsmn.c is in the project.
b) I used extern "C" , but the same problem.
2019-07-18 08:23 AM
The linker seems to disagree, perhaps you need to disassemble the objects and see what symbols are actually inside them.
Not sure if the IAR linker outputs a .MAP on failure cases, or if there are options for verbose output, etc.
2019-07-18 08:39 AM
@Community member
I don't know why but when I add this line (Data_t DATA); in main.cpp the error disappear.
2019-07-18 09:19 AM
I know now what is the problem the Data_t DATA was declared localy on a function in jsmn.c , I declare Data_t DATA globally and I elimineted this declaration in main.cpp