I want get the address of exit library function and then assign this address to a global variable.
  //test3.c
  1 #include <stdio.h>
  2 #include <stdlib.h>
  3 
  4   int fp = &exit;
  5 
  6 int main(){
  7   printf("fp=%d\n",fp);
  8   return 0;
  9 }
But one error comes out when I compile the above test3.c program using gcc.
$ gcc -o test3 test3.c
test3.c:4:12: warning: initialization makes integer from pointer without a cast [enabled by default]
test3.c:4:3: error: initializer element is not computable at load time
When I get and assign the address of exit to a local variable in main function, there is no error.
  //test4.c
  1 #include <stdio.h>
  2 #include <stdlib.h>
  3 
  4 int main(){
  5   int fp = &exit;
  6   printf("fp=%d\n",fp);
  7   return 0;
  8 }
I can print the result:
$ gcc -o test4 test4.c
test4.c: In function ‘main’:
test4.c:5:12: warning: initialization makes integer from pointer without a cast [enabled by default]
$ ./test4
fp=4195408
How can I assign the address of exit to a global variable?
 
    