daily pastebin goal
7%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ gcc -o scriptedmain scriptedmain.c scriptedmain.h
  2. $ ./scriptedmain
  3. Main: The meaning of life is 42
  4. $ gcc -o test test.c scriptedmain.c scriptedmain.h
  5. $ ./test
  6. Test: The meaning of life is 42
  7.    
  8. int meaning_of_life();
  9.    
  10. #include <stdio.h>
  11.  
  12. int meaning_of_life() {
  13.     return 42;
  14. }
  15.  
  16. int __attribute__((weak)) main() {
  17.     printf("Main: The meaning of life is %dn", meaning_of_life());
  18.  
  19.     return 0;
  20. }
  21.    
  22. #include "scriptedmain.h"
  23. #include <stdio.h>
  24.  
  25. extern int meaning_of_life();
  26.  
  27. int main() {
  28.     printf("Test: The meaning of life is %dn", meaning_of_life());
  29.     return 0;
  30. }
  31.    
  32. C:>gcc -o scriptedmain scriptedmain.c scriptedmain.h
  33. c:/strawberry/c/bin/../lib/gcc/i686-w64-mingw32/4.4.3/../../../../i686-w64-mingw32/lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o): In function `main':
  34. /opt/W64_156151-src.32/build-crt/../mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain@16'
  35. collect2: ld returned 1 exit status
  36.    
  37. $ gcc -o scriptedmain -mwindows scriptedmain.c scriptedmain.h
  38. c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain@16'
  39. collect2: ld returned 1 exit status
  40.    
  41. #include <stdio.h>
  42.  
  43. int meaning_of_life() {
  44.     return 42;
  45. }
  46.  
  47. #ifdef SCRIPTEDMAIN
  48.  
  49. int main() {
  50.     printf("Main: The meaning of life is %dn", meaning_of_life());
  51.  
  52.     return 0;
  53. }
  54.  
  55. #endif
  56.    
  57. gcc -o scriptedmain -DSCRIPTEDMAIN scriptedmain.c scriptedmain.h
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top