Reputation: 4095
Why can't lldb's expression
understand my C Struct unless I declare a default variable?
struct YD_MENU {
char menu_name[10];
int menu_option;
};
int main() {
return 0;
}
Adding a breakpoint inside of main...
(lldb) exp struct YD_MENU $b
error: variable has incomplete type 'struct YD_MENU'
forward declaration of 'YD_MENU'
If I change it to the following...
struct YD_MENU {
char menu_name[10];
int menu_option;
} default_menu;
(lldb) exp struct YD_MENU $a
works fine.
I think this is related to Why can't LLDB evaluate this expression? but the proposed answers don't work.
(lldb) version
lldb-1000.0.29
Upvotes: 1
Views: 304
Reputation: 27148
clang (and gcc as well) are fairly aggressive about not emitting type information for "unused types". There are so many types floating around when you do something like import <Cocoa/Cocoa.h>
that it has to do this to keep debug information size reasonable. That's why when you define a structure but don't use it, lldb can't see the type. The information about the type is in fact not there for lldb to see.
Upvotes: 3