Fix gv for long longs
[tinycc/daniel.git] / libtcc.h
blob6cacd732745e897519e28c09f0720a0781bc669a
1 #ifndef LIBTCC_H
2 #define LIBTCC_H
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
8 struct TCCState;
10 typedef struct TCCState TCCState;
12 /* create a new TCC compilation context */
13 TCCState *tcc_new(void);
15 /* free a TCC compilation context */
16 void tcc_delete(TCCState *s);
18 /* add debug information in the generated code */
19 void tcc_enable_debug(TCCState *s);
21 /* set error/warning display callback */
22 void tcc_set_error_func(TCCState *s, void *error_opaque,
23 void (*error_func)(void *opaque, const char *msg));
25 /* set/reset a warning */
26 int tcc_set_warning(TCCState *s, const char *warning_name, int value);
28 /*****************************/
29 /* preprocessor */
31 /* add include path */
32 int tcc_add_include_path(TCCState *s, const char *pathname);
34 /* add in system include path */
35 int tcc_add_sysinclude_path(TCCState *s, const char *pathname);
37 /* define preprocessor symbol 'sym'. Can put optional value */
38 void tcc_define_symbol(TCCState *s, const char *sym, const char *value);
40 /* undefine preprocess symbol 'sym' */
41 void tcc_undefine_symbol(TCCState *s, const char *sym);
43 /*****************************/
44 /* compiling */
46 /* add a file (either a C file, dll, an object, a library or an ld
47 script). Return -1 if error. */
48 int tcc_add_file(TCCState *s, const char *filename);
50 /* compile a string containing a C source. Return non zero if
51 error. */
52 int tcc_compile_string(TCCState *s, const char *buf);
54 /*****************************/
55 /* linking commands */
57 /* set output type. MUST BE CALLED before any compilation */
58 #define TCC_OUTPUT_MEMORY 0 /* output will be ran in memory (no
59 output file) (default) */
60 #define TCC_OUTPUT_EXE 1 /* executable file */
61 #define TCC_OUTPUT_DLL 2 /* dynamic library */
62 #define TCC_OUTPUT_OBJ 3 /* object file */
63 #define TCC_OUTPUT_PREPROCESS 4 /* preprocessed file (used internally) */
64 int tcc_set_output_type(TCCState *s, int output_type);
66 #define TCC_OUTPUT_FORMAT_ELF 0 /* default output format: ELF */
67 #define TCC_OUTPUT_FORMAT_BINARY 1 /* binary image output */
68 #define TCC_OUTPUT_FORMAT_COFF 2 /* COFF */
70 /* equivalent to -Lpath option */
71 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 int tcc_add_library(TCCState *s, const char *libraryname);
76 /* add a symbol to the compiled program */
77 int tcc_add_symbol(TCCState *s, const char *name, unsigned long val);
79 /* output an executable, library or object file. DO NOT call
80 tcc_relocate() before. */
81 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 int tcc_run(TCCState *s, int argc, char **argv);
87 /* do all relocations (needed before using tcc_get_symbol()). Return
88 non zero if link error. */
89 int tcc_relocate(TCCState *s);
91 /* return symbol value. return 0 if OK, -1 if symbol not found */
92 int tcc_get_symbol(TCCState *s, unsigned long *pval, const char *name);
94 #ifdef __cplusplus
96 #endif
98 #endif