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 /* set CONFIG_TCCDIR at runtime */
23 LIBTCCAPI
void tcc_set_lib_path(TCCState
*s
, const char *path
);
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 options as from command line (multiple supported) */
30 LIBTCCAPI
void tcc_set_options(TCCState
*s
, const char *str
);
32 /*****************************/
35 /* add in tcc include path, searched before anything else */
36 LIBTCCAPI
int tcc_add_tccinclude_path(TCCState
*s
, const char *pathname
);
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 (C file, dll, object, library, ld 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 -1 if error. */
57 LIBTCCAPI
int tcc_compile_string(TCCState
*s
, const char *buf
);
59 /*****************************/
60 /* linking commands */
62 /* set output type. MUST BE CALLED before any compilation */
63 LIBTCCAPI
int tcc_set_output_type(TCCState
*s
, int output_type
);
64 #define TCC_OUTPUT_MEMORY 1 /* output will be run in memory (default) */
65 #define TCC_OUTPUT_EXE 2 /* executable file */
66 #define TCC_OUTPUT_DLL 3 /* dynamic library */
67 #define TCC_OUTPUT_OBJ 4 /* object file */
68 #define TCC_OUTPUT_PREPROCESS 5 /* only preprocess (used internally) */
70 /* equivalent to -Lpath option */
71 LIBTCCAPI
int tcc_add_library_path(TCCState
*s
, const char *pathname
);
73 /* the library name is the same as the argument of the '-l' option */
74 LIBTCCAPI
int tcc_add_library(TCCState
*s
, const char *libraryname
);
76 /* add a symbol to the compiled program */
77 LIBTCCAPI
int tcc_add_symbol(TCCState
*s
, const char *name
, const void *val
);
79 /* output an executable, library or object file. DO NOT call
80 tcc_relocate() before. */
81 LIBTCCAPI
int tcc_output_file(TCCState
*s
, const char *filename
);
83 /* link and run main() function and return its value. DO NOT call
84 tcc_relocate() before. */
85 LIBTCCAPI
int tcc_run(TCCState
*s
, int argc
, char **argv
);
87 /* do all relocations (needed before using tcc_get_symbol()) */
88 LIBTCCAPI
int tcc_relocate(TCCState
*s1
, void *ptr
);
89 /* possible values for 'ptr':
90 - TCC_RELOCATE_AUTO : Allocate and manage memory internally
91 - NULL : return required memory size for the step below
92 - memory address : copy code to memory passed by the caller
93 returns -1 if error. */
94 #define TCC_RELOCATE_AUTO (void*)1
96 /* return symbol value or NULL if not found */
97 LIBTCCAPI
void *tcc_get_symbol(TCCState
*s
, const char *name
);