5 #define LIBTCCAPI __declspec(dllexport)
16 typedef struct TCCState TCCState
;
18 /* create a new TCC compilation context */
19 LIBTCCAPI TCCState
*tcc_new(void);
21 /* free a TCC compilation context */
22 LIBTCCAPI
void tcc_delete(TCCState
*s
);
24 /* add debug information in the generated code */
25 LIBTCCAPI
void tcc_enable_debug(TCCState
*s
);
27 /* set error/warning display callback */
28 LIBTCCAPI
void tcc_set_error_func(TCCState
*s
, void *error_opaque
,
29 void (*error_func
)(void *opaque
, const char *msg
));
31 /* set/reset a warning */
32 LIBTCCAPI
int tcc_set_warning(TCCState
*s
, const char *warning_name
, int value
);
34 /*****************************/
37 /* add include path */
38 LIBTCCAPI
int tcc_add_include_path(TCCState
*s
, const char *pathname
);
40 /* add in system include path */
41 LIBTCCAPI
int tcc_add_sysinclude_path(TCCState
*s
, const char *pathname
);
43 /* define preprocessor symbol 'sym'. Can put optional value */
44 LIBTCCAPI
void tcc_define_symbol(TCCState
*s
, const char *sym
, const char *value
);
46 /* undefine preprocess symbol 'sym' */
47 LIBTCCAPI
void tcc_undefine_symbol(TCCState
*s
, const char *sym
);
49 /*****************************/
52 /* add a file (either a C file, dll, an object, a library or an ld
53 script). Return -1 if error. */
54 LIBTCCAPI
int tcc_add_file(TCCState
*s
, const char *filename
);
56 /* compile a string containing a C source. Return non zero if
58 LIBTCCAPI
int tcc_compile_string(TCCState
*s
, const char *buf
);
60 /*****************************/
61 /* linking commands */
63 /* set output type. MUST BE CALLED before any compilation */
64 #define TCC_OUTPUT_MEMORY 0 /* output will be ran in memory (no
65 output file) (default) */
66 #define TCC_OUTPUT_EXE 1 /* executable file */
67 #define TCC_OUTPUT_DLL 2 /* dynamic library */
68 #define TCC_OUTPUT_OBJ 3 /* object file */
69 #define TCC_OUTPUT_PREPROCESS 4 /* preprocessed file (used internally) */
70 LIBTCCAPI
int tcc_set_output_type(TCCState
*s
, int output_type
);
72 #define TCC_OUTPUT_FORMAT_ELF 0 /* default output format: ELF */
73 #define TCC_OUTPUT_FORMAT_BINARY 1 /* binary image output */
74 #define TCC_OUTPUT_FORMAT_COFF 2 /* COFF */
76 /* equivalent to -Lpath option */
77 LIBTCCAPI
int tcc_add_library_path(TCCState
*s
, const char *pathname
);
79 /* the library name is the same as the argument of the '-l' option */
80 LIBTCCAPI
int tcc_add_library(TCCState
*s
, const char *libraryname
);
82 /* add a symbol to the compiled program */
83 LIBTCCAPI
int tcc_add_symbol(TCCState
*s
, const char *name
, void *val
);
85 /* output an executable, library or object file. DO NOT call
86 tcc_relocate() before. */
87 LIBTCCAPI
int tcc_output_file(TCCState
*s
, const char *filename
);
89 /* link and run main() function and return its value. DO NOT call
90 tcc_relocate() before. */
91 LIBTCCAPI
int tcc_run(TCCState
*s
, int argc
, char **argv
);
93 /* copy code into memory passed in by the caller and do all relocations
94 (needed before using tcc_get_symbol()).
95 returns -1 on error and required size if ptr is NULL */
96 LIBTCCAPI
int tcc_relocate(TCCState
*s1
, void *ptr
);
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
);