Changeset 331 for EcnlProtoTool/trunk/tcc-0.9.27/tests/libtcc_test.c
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/tcc-0.9.27
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/tcc-0.9.27/tests/libtcc_test.c
r321 r331 16 16 } 17 17 18 /* this strinc is referenced by the generated code */ 19 const char hello[] = "Hello World!"; 20 18 21 char my_program[] = 22 "#include <tcclib.h>\n" /* include the "Simple libc header for TCC" */ 23 "extern int add(int a, int b);\n" 24 "#ifdef _WIN32\n" /* dynamically linked data needs 'dllimport' */ 25 " __attribute__((dllimport))\n" 26 "#endif\n" 27 "extern const char hello[];\n" 19 28 "int fib(int n)\n" 20 29 "{\n" … … 27 36 "int foo(int n)\n" 28 37 "{\n" 29 " printf(\" Hello World!\\n\");\n"38 " printf(\"%s\\n\", hello);\n" 30 39 " printf(\"fib(%d) = %d\\n\", n, fib(n));\n" 31 40 " printf(\"add(%d, %d) = %d\\n\", n, 2 * n, add(n, 2 * n));\n" … … 36 45 { 37 46 TCCState *s; 47 int i; 38 48 int (*func)(int); 39 49 … … 45 55 46 56 /* if tcclib.h and libtcc1.a are not installed, where can we find them */ 47 if (argc == 2 && !memcmp(argv[1], "lib_path=",9)) 48 tcc_set_lib_path(s, argv[1]+9); 57 for (i = 1; i < argc; ++i) { 58 char *a = argv[i]; 59 if (a[0] == '-') { 60 if (a[1] == 'B') 61 tcc_set_lib_path(s, a+2); 62 else if (a[1] == 'I') 63 tcc_add_include_path(s, a+2); 64 else if (a[1] == 'L') 65 tcc_add_library_path(s, a+2); 66 } 67 } 49 68 50 69 /* MUST BE CALLED before any compilation */ … … 54 73 return 1; 55 74 56 /* as a test, we add a symbolthat the compiled program can use.75 /* as a test, we add symbols that the compiled program can use. 57 76 You may also open a dll with tcc_add_dll() and use symbols from that */ 58 77 tcc_add_symbol(s, "add", add); 78 tcc_add_symbol(s, "hello", hello); 59 79 60 80 /* relocate the code */
Note:
See TracChangeset
for help on using the changeset viewer.