added libtcc
[tinycc.git] / libtcc.h
blob11378ed063b66b1d16da8a4906f2649e9da0a2f1
1 #ifndef LIBTCC_H
2 #define LIBTCC_H
4 struct TCCState;
6 typedef struct TCCState TCCState;
8 /* create a new TCC compilation context */
9 TCCState *tcc_new(void);
11 /* free a TCC compilation context */
12 void tcc_delete(TCCState *s);
14 /* add debug information in the generated code */
15 void tcc_enable_debug(TCCState *s);
17 /*****************************/
18 /* preprocessor */
20 /* add include path */
21 int tcc_add_include_path(TCCState *s, const char *pathname);
23 /* define preprocessor symbol 'sym'. Can put optional value */
24 void tcc_define_symbol(TCCState *s, const char *sym, const char *value);
26 /* undefine preprocess symbol 'sym' */
27 void tcc_undefine_symbol(TCCState *s, const char *sym);
29 /*****************************/
30 /* compiling */
32 /* compile a file. Return non zero if error. */
33 int tcc_compile_file(TCCState *s, const char *filename);
35 /* compile a string. Return non zero if error. */
36 int tcc_compile_string(TCCState *s, const char *buf);
38 /* get last error */
39 int tcc_get_error(TCCState *s, char *buf, int buf_size);
41 /*****************************/
42 /* linking commands */
44 /* add a DYNAMIC library so that the compiled program can use its symbols */
45 int tcc_add_dll(TCCState *s, const char *library_name);
47 /* define a global symbol */
48 int tcc_add_symbol(TCCState *s, const char *name, void *value);
50 #define TCC_FILE_EXE 0 /* executable file */
51 #define TCC_FILE_DLL 1 /* dynamic library */
52 #define TCC_FILE_OBJ 2 /* object file */
54 /* output an executable file */
55 int tcc_output_file(TCCState *s, const char *filename, int file_type);
57 /* link and run main() function and return its value */
58 int tcc_run(TCCState *s, int argc, char **argv);
60 #endif