14 typedef struct TCCState TCCState
;
16 /* create a new TCC compilation context */
17 LIBTCCAPI TCCState
*tcc_new(void);
19 /* free a TCC compilation context */
20 LIBTCCAPI
void tcc_delete(TCCState
*s
);
22 /* add debug information in the generated code */
23 LIBTCCAPI
void tcc_enable_debug(TCCState
*s
);
25 /* set error/warning display callback */
26 LIBTCCAPI
void tcc_set_error_func(TCCState
*s
, void *error_opaque
,
27 void (*error_func
)(void *opaque
, const char *msg
));
29 /* set/reset a warning */
30 LIBTCCAPI
int tcc_set_warning(TCCState
*s
, const char *warning_name
, int value
);
32 /* set linker option */
33 LIBTCCAPI
const char * tcc_set_linker(TCCState
*s
, char *option
, int multi
);
35 /*****************************/
38 /* add include path */
39 LIBTCCAPI
int tcc_add_include_path(TCCState
*s
, const char *pathname
);
41 /* add in system include path */
42 LIBTCCAPI
int tcc_add_sysinclude_path(TCCState
*s
, const char *pathname
);
44 /* define preprocessor symbol 'sym'. Can put optional value */
45 LIBTCCAPI
void tcc_define_symbol(TCCState
*s
, const char *sym
, const char *value
);
47 /* undefine preprocess symbol 'sym' */
48 LIBTCCAPI
void tcc_undefine_symbol(TCCState
*s
, const char *sym
);
50 /*****************************/
53 /* add a file (either a C file, dll, an object, a library or an ld
54 script). Return -1 if error. */
55 LIBTCCAPI
int tcc_add_file(TCCState
*s
, const char *filename
);
57 /* compile a string containing a C source. Return non zero if
59 LIBTCCAPI
int tcc_compile_string(TCCState
*s
, const char *buf
);
61 /*****************************/
62 /* linking commands */
64 /* set output type. MUST BE CALLED before any compilation */
65 #define TCC_OUTPUT_MEMORY 0 /* output will be ran in memory (no
66 output file) (default) */
67 #define TCC_OUTPUT_EXE 1 /* executable file */
68 #define TCC_OUTPUT_DLL 2 /* dynamic library */
69 #define TCC_OUTPUT_OBJ 3 /* object file */
70 #define TCC_OUTPUT_PREPROCESS 4 /* preprocessed file (used internally) */
71 LIBTCCAPI
int tcc_set_output_type(TCCState
*s
, int output_type
);
73 #define TCC_OUTPUT_FORMAT_ELF 0 /* default output format: ELF */
74 #define TCC_OUTPUT_FORMAT_BINARY 1 /* binary image output */
75 #define TCC_OUTPUT_FORMAT_COFF 2 /* COFF */
77 /* equivalent to -Lpath option */
78 LIBTCCAPI
int tcc_add_library_path(TCCState
*s
, const char *pathname
);
80 /* the library name is the same as the argument of the '-l' option */
81 LIBTCCAPI
int tcc_add_library(TCCState
*s
, const char *libraryname
);
83 /* add a symbol to the compiled program */
84 LIBTCCAPI
int tcc_add_symbol(TCCState
*s
, const char *name
, const void *val
);
86 /* output an executable, library or object file. DO NOT call
87 tcc_relocate() before. */
88 LIBTCCAPI
int tcc_output_file(TCCState
*s
, const char *filename
);
90 /* link and run main() function and return its value. DO NOT call
91 tcc_relocate() before. */
92 LIBTCCAPI
int tcc_run(TCCState
*s
, int argc
, char **argv
);
94 /* Do all relocations (needed before using tcc_get_symbol())
95 Returns -1 on error. */
96 LIBTCCAPI
int tcc_relocate(TCCState
*s1
);
98 /* return symbol value or NULL if not found */
99 LIBTCCAPI
void *tcc_get_symbol(TCCState
*s
, const char *name
);
101 /* set CONFIG_TCCDIR at runtime */
102 LIBTCCAPI
void tcc_set_lib_path(TCCState
*s
, const char *path
);