api change
[tinycc.git] / libtcc.h
blob7b884a149a9751d6035e4890c0461703d5db4eef
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 /* add a file (either a C file, dll, an object, a library or an ld
33 script */
34 void tcc_add_file(TCCState *s, const char *filename);
36 /* compile a string containing a C source. Return non zero if
37 error. */
38 int tcc_compile_string(TCCState *s, const char *buf);
40 /* get last error */
41 int tcc_get_error(TCCState *s, char *buf, int buf_size);
43 /*****************************/
44 /* linking commands */
46 /* set output type. Must be called before any compilation */
47 #define TCC_OUTPUT_MEMORY 0 /* output will be ran in memory (no
48 output file) (default) */
49 #define TCC_OUTPUT_EXE 1 /* executable file */
50 #define TCC_OUTPUT_DLL 2 /* dynamic library */
51 #define TCC_OUTPUT_OBJ 3 /* object file */
52 int tcc_set_output_type(TCCState *s, int output_type);
54 /* equivalent to -Lpath option */
55 int tcc_add_library_path(TCCState *s, const char *pathname);
57 /* the library name is the same as the argument of the '-l' option */
58 int tcc_add_library(TCCState *s, const char *libraryname);
60 /* add a symbol to the compiled program */
61 int tcc_add_symbol(TCCState *s, const char *name, unsigned long val);
63 /* output an executable file */
64 int tcc_output_file(TCCState *s, const char *filename);
66 /* link and run main() function and return its value */
67 int tcc_run(TCCState *s, int argc, char **argv);
69 #endif