Skip to content

How to create a function pointer and call it? #833

@oneengineer

Description

@oneengineer
int (*sum_func)(int, int) = (int (*)(int, int))LLVMGetFunctionAddress(engine, "sum");

I need to call LLVMGetFunctionAddress like the C code above in Java, however it returns a pointer and I need to convert it to (int (*)(int, int)) function.

More specifically, I guess the code would be like:

long funAddr = LLVMGetFunctionAddress(engine, "sum")

new Pointer {

   //someshow pass the funAddr to it

   public native void call( /*parameters here*/ );

}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions