C言語におけるリフレクション(2)
とりあえず、仮想メモリ空間上のアドレスさえ分かれば呼べるらしい。
#include <stdio.h>
void func1()
{
printf("this is func1\n");
return;
}
int main(int argc, char* argv[])
{
printf("func1 is %p\n", func1);
void (*func)();
func = (void*) 0x80483a0; //事前に調べた :P
printf("func is %p\n", func);
func();
return 0;
}ビルド&実行
mir@t43:~/scratch$ gcc -Wall -o foo foo.c mir@t43:~/scratch$ ./foo func1 is 0x80483a0 func is 0x80483a0 this is func1