cancel
Showing results for 
Search instead for 
Did you mean: 

Please explain why I get errors here even after I have added include files?

RCooke88
Senior

Hi Folks,

I'm getting an error that is driving me crazy. The first occurrence of the variable is OK but the next one is flagged as "

"undefined reference to `lv_disp_get_default'"

 

 

static inline struct _lv_obj_t * lv_layer_top(void)
{
    return lv_disp_get_layer_top(lv_disp_get_default());
}

static inline struct _lv_obj_t * lv_scr_act(void)
{
    return lv_disp_get_scr_act(lv_disp_get_default()); <---- Error here
}

 

Why would the second "lv_disp_get_default()" cause an error when the first one doesn't?

This is in lv_disp.h file. the lv_disp_get_default() is defined in the lv_disp.c file.

lv_disp_t * lv_disp_get_default(void)

{

return disp_def;

}

Any ideas what I can try to resolve this issue?

Thanks,

Richard

3 REPLIES 3

Undefined reference sounds like a linker error, not a compiler one.

Include files typically don't provide code, the body code lives in other object(s) that will need to be pulled in elsewhere. There may also be namespace or scope issues depending on where and how the body code is expressed. ie static, in .cpp files, etc.

Review the context of use, grep the source and project to understand where things are coming from. 

inline won't manifest code unless used. The compiler will generate a call to the function, and move on. Your error suggests the linker can't close the loop on that. It's not seeing the function name at it's level, from all the objects you've furnished it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
RCooke88
Senior

Tesla,

Thanks for the info. But would that explain why the first function is OK but the second one causes an error?

Because it's actually used?

This is presumably the Linker indicating it can't get closure, not the compiler encountering code in the file in a linear sense.

The use context will determine how the compiler inlines or folds the code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..