Last active
August 14, 2017 05:59
-
-
Save liyang85105/58ca8e74115041ad8add9b41720597ad to your computer and use it in GitHub Desktop.
specify entry point of a c/c++ program instead of main
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/*extern "C"*/ int sum(int a, int b) | |
{ | |
return 2 * a + 3 * b; | |
} | |
/*extern "C"*/ int entry() | |
{ | |
printf("this is call from function test\n"); | |
printf("result of sum(1,2) = %d\n", sum(1,2)); | |
exit(0); | |
} | |
//int main() | |
//{ | |
// printf("this is call from function main\n"); | |
// return 0; | |
//} | |
// compile command | |
// gcc -fPIE -nostartfiles no_main.c -Wl,-eentry -o no_main | |
or | |
// gcc -fPIE -nostartfiles -e entry no_main.c -o no_main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment