Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
145 | halyavin | 1 | #ifndef LIBTCC_H |
2 | #define LIBTCC_H |
||
3 | |||
4 | #ifdef __cplusplus |
||
5 | extern "C" { |
||
6 | #endif |
||
7 | |||
8 | struct TCCState; |
||
9 | |||
10 | typedef struct TCCState TCCState; |
||
11 | |||
12 | /* create a new TCC compilation context */ |
||
13 | TCCState *tcc_new(void); |
||
14 | |||
15 | /* free a TCC compilation context */ |
||
16 | void tcc_delete(TCCState *s); |
||
17 | |||
18 | /* add debug information in the generated code */ |
||
19 | void tcc_enable_debug(TCCState *s); |
||
20 | |||
21 | /* set error/warning display callback */ |
||
22 | void tcc_set_error_func(TCCState *s, void *error_opaque, |
||
23 | void (*error_func)(void *opaque, const char *msg)); |
||
24 | |||
25 | /* set/reset a warning */ |
||
26 | int tcc_set_warning(TCCState *s, const char *warning_name, int value); |
||
27 | |||
28 | /*****************************/ |
||
29 | /* preprocessor */ |
||
30 | |||
31 | /* add include path */ |
||
32 | int tcc_add_include_path(TCCState *s, const char *pathname); |
||
33 | |||
34 | /* add in system include path */ |
||
35 | int tcc_add_sysinclude_path(TCCState *s, const char *pathname); |
||
36 | |||
37 | /* define preprocessor symbol 'sym'. Can put optional value */ |
||
38 | void tcc_define_symbol(TCCState *s, const char *sym, const char *value); |
||
39 | |||
40 | /* undefine preprocess symbol 'sym' */ |
||
41 | void tcc_undefine_symbol(TCCState *s, const char *sym); |
||
42 | |||
43 | /*****************************/ |
||
44 | /* compiling */ |
||
45 | |||
46 | /* add a file (either a C file, dll, an object, a library or an ld |
||
47 | script). Return -1 if error. */ |
||
48 | int tcc_add_file(TCCState *s, const char *filename); |
||
49 | |||
50 | /* compile a string containing a C source. Return non zero if |
||
51 | error. */ |
||
52 | int tcc_compile_string(TCCState *s, const char *buf); |
||
53 | |||
54 | /*****************************/ |
||
55 | /* linking commands */ |
||
56 | |||
57 | /* set output type. MUST BE CALLED before any compilation */ |
||
58 | #define TCC_OUTPUT_MEMORY 0 /* output will be ran in memory (no |
||
59 | output file) (default) */ |
||
60 | #define TCC_OUTPUT_EXE 1 /* executable file */ |
||
61 | #define TCC_OUTPUT_DLL 2 /* dynamic library */ |
||
62 | #define TCC_OUTPUT_OBJ 3 /* object file */ |
||
63 | int tcc_set_output_type(TCCState *s, int output_type); |
||
64 | |||
65 | #define TCC_OUTPUT_FORMAT_ELF 0 /* default output format: ELF */ |
||
66 | #define TCC_OUTPUT_FORMAT_BINARY 1 /* binary image output */ |
||
67 | #define TCC_OUTPUT_FORMAT_COFF 2 /* COFF */ |
||
68 | |||
69 | /* equivalent to -Lpath option */ |
||
70 | int tcc_add_library_path(TCCState *s, const char *pathname); |
||
71 | |||
72 | /* the library name is the same as the argument of the '-l' option */ |
||
73 | int tcc_add_library(TCCState *s, const char *libraryname); |
||
74 | |||
75 | /* add a symbol to the compiled program */ |
||
76 | int tcc_add_symbol(TCCState *s, const char *name, unsigned long val); |
||
77 | |||
78 | /* output an executable, library or object file. DO NOT call |
||
79 | tcc_relocate() before. */ |
||
80 | int tcc_output_file(TCCState *s, const char *filename); |
||
81 | |||
82 | /* link and run main() function and return its value. DO NOT call |
||
83 | tcc_relocate() before. */ |
||
84 | int tcc_run(TCCState *s, int argc, char **argv); |
||
85 | |||
86 | /* do all relocations (needed before using tcc_get_symbol()). Return |
||
87 | non zero if link error. */ |
||
88 | int tcc_relocate(TCCState *s); |
||
89 | |||
90 | /* return symbol value. return 0 if OK, -1 if symbol not found */ |
||
91 | int tcc_get_symbol(TCCState *s, unsigned long *pval, const char *name); |
||
92 | |||
93 | #ifdef __cplusplus |
||
94 | } |
||
95 | #endif |
||
96 | |||
97 | #endif |