10 typedef struct TCCState TCCState
;
12 /* create a new TCC compilation context */
13 TCCState
*tcc_new(void);
15 /* free a TCC compilation context */
16 void tcc_delete(TCCState
*s
);
18 /* add debug information in the generated code */
19 void tcc_enable_debug(TCCState
*s
);
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
));
25 /* set/reset a warning */
26 int tcc_set_warning(TCCState
*s
, const char *warning_name
, int value
);
28 /*****************************/
31 /* add include path */
32 int tcc_add_include_path(TCCState
*s
, const char *pathname
);
34 /* add in system include path */
35 int tcc_add_sysinclude_path(TCCState
*s
, const char *pathname
);
37 /* define preprocessor symbol 'sym'. Can put optional value */
38 void tcc_define_symbol(TCCState
*s
, const char *sym
, const char *value
);
40 /* undefine preprocess symbol 'sym' */
41 void tcc_undefine_symbol(TCCState
*s
, const char *sym
);
43 /*****************************/
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
);
50 /* compile a string containing a C source. Return non zero if
52 int tcc_compile_string(TCCState
*s
, const char *buf
);
54 /*****************************/
55 /* linking commands */
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
);
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 */
69 /* equivalent to -Lpath option */
70 int tcc_add_library_path(TCCState
*s
, const char *pathname
);
72 /* the library name is the same as the argument of the '-l' option */
73 int tcc_add_library(TCCState
*s
, const char *libraryname
);
75 /* add a symbol to the compiled program */
76 int tcc_add_symbol(TCCState
*s
, const char *name
, unsigned long val
);
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
);
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
);
86 /* do all relocations (needed before using tcc_get_symbol()). Return
87 non zero if link error. */
88 int tcc_relocate(TCCState
*s
);
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
);