Skip to content

feat:gen a named func type for anonymous func pointer in struct. #448

Description

@luoliwoshang
typedefstructHooks {
void*(*malloc_fn)(size_tsz);
void (*free_fn)(void*ptr);
} Hooks;
typeHooksstruct {
MallocFn c.PointerFreeFn c.Pointer
}

Due to the characteristics of LLGo, an anonymous function type cannot be directly declared as a Field Type. Currently, the Field Type for an anonymous function is only mapped to c.Pointer, but this causes the original type information to be lost. To solve this problem, we can additionally declare a function type annotated with llgo:type C and reference it.

typedefstructHooks {
void*(*malloc_fn)(size_tsz);
void (*free_fn)(void*ptr);
} Hooks;
// llgo:type CtypeLLGO_HOOKS_MallocFnfunc(c.SizeT) c.Pointer// llgo:type CtypeLLGO_HOOKS_FreeFnfunc(c.Pointer)
typeHooksstruct {
MallocFnLLGO_HOOKS_MallocFnFreeFnLLGO_HOOKS_FreeFn
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions