Bionix1441 Bionix1441 - 1 month ago 5x
C Question

Cast a function pointer to a long

I am not sure if that is feasible, but I need to cast a function pointer to long in order to map C level code back to java code.


a pointer's value is a integer,you just need know what exactly you are doing and alloc enough storage to store the pointer's value.(int a 32bit os,pointer occupy 32bit storage,int a 64bit os,pointer occupy 64bit storage).

a c example:

#include <stdio.h>

void fun()

typedef void (*fun_type)();

int main()
    long long int a = (long long int)fun;

    fun_type func_point = (fun_type)a;

    return 0;