In C++, is it possible for main to be defined by a function pointer? For example:
int f(int, char**) {
return 0;
}
int (*main)(int, char**) = &f;
This code compiles and links correctly, but triggers a segmentation fault when it's run. I believe that may be because it's trying to execute the value of the function pointer as code.
Additionally, if it's not possible in plain C++, then can it be achieved by non-standard features of gcc (maybe somehow changing the type of the exported symbol).
Finally, if it can't be achieved with gcc directives, can it be done with a custom linker script?