Skip to main content
RCooke88
Associate III
October 10, 2023
Question

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

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

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    October 10, 2023

    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    RCooke88
    RCooke88Author
    Associate III
    October 10, 2023

    Tesla,

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

    Tesla DeLorean
    Guru
    October 10, 2023

    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..