Subversion Repositories Kolibri OS

Rev

Rev 647 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
145 halyavin 1
#ifndef LIBTCC_H
2
#define LIBTCC_H
3
 
6429 siemargl 4
#ifndef LIBTCCAPI
5
# define LIBTCCAPI
6
#endif
7
 
145 halyavin 8
#ifdef __cplusplus
9
extern "C" {
10
#endif
11
 
12
struct TCCState;
13
 
14
typedef struct TCCState TCCState;
15
 
16
/* create a new TCC compilation context */
6429 siemargl 17
LIBTCCAPI TCCState *tcc_new(void);
145 halyavin 18
 
19
/* free a TCC compilation context */
6429 siemargl 20
LIBTCCAPI void tcc_delete(TCCState *s);
145 halyavin 21
 
6429 siemargl 22
/* set CONFIG_TCCDIR at runtime */
23
LIBTCCAPI void tcc_set_lib_path(TCCState *s, const char *path);
145 halyavin 24
 
25
/* set error/warning display callback */
6429 siemargl 26
LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque,
27
    void (*error_func)(void *opaque, const char *msg));
145 halyavin 28
 
6429 siemargl 29
/* set options as from command line (multiple supported) */
30
LIBTCCAPI int tcc_set_options(TCCState *s, const char *str);
145 halyavin 31
 
32
/*****************************/
33
/* preprocessor */
34
 
35
/* add include path */
6429 siemargl 36
LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname);
145 halyavin 37
 
38
/* add in system include path */
6429 siemargl 39
LIBTCCAPI int tcc_add_sysinclude_path(TCCState *s, const char *pathname);
145 halyavin 40
 
41
/* define preprocessor symbol 'sym'. Can put optional value */
6429 siemargl 42
LIBTCCAPI void tcc_define_symbol(TCCState *s, const char *sym, const char *value);
145 halyavin 43
 
44
/* undefine preprocess symbol 'sym' */
6429 siemargl 45
LIBTCCAPI void tcc_undefine_symbol(TCCState *s, const char *sym);
145 halyavin 46
 
47
/*****************************/
48
/* compiling */
49
 
6429 siemargl 50
/* add a file (C file, dll, object, library, ld script). Return -1 if error. */
51
LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename, int filetype);
52
#define TCC_FILETYPE_BINARY 1
53
#define TCC_FILETYPE_C      2
54
#define TCC_FILETYPE_ASM    3
55
#define TCC_FILETYPE_ASM_PP 4
145 halyavin 56
 
6429 siemargl 57
/* compile a string containing a C source. Return -1 if error. */
58
LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf);
145 halyavin 59
 
60
/*****************************/
61
/* linking commands */
62
 
63
/* set output type. MUST BE CALLED before any compilation */
6429 siemargl 64
LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type);
65
#define TCC_OUTPUT_MEMORY   1 /* output will be run in memory (default) */
66
#define TCC_OUTPUT_EXE      2 /* executable file */
67
#define TCC_OUTPUT_DLL      3 /* dynamic library */
68
#define TCC_OUTPUT_OBJ      4 /* object file */
69
#define TCC_OUTPUT_PREPROCESS 5 /* only preprocess (used internally) */
145 halyavin 70
 
71
/* equivalent to -Lpath option */
6429 siemargl 72
LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname);
145 halyavin 73
 
74
/* the library name is the same as the argument of the '-l' option */
6429 siemargl 75
LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname);
145 halyavin 76
 
77
/* add a symbol to the compiled program */
6429 siemargl 78
LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val);
145 halyavin 79
 
80
/* output an executable, library or object file. DO NOT call
81
   tcc_relocate() before. */
6429 siemargl 82
LIBTCCAPI int tcc_output_file(TCCState *s, const char *filename);
145 halyavin 83
 
84
/* link and run main() function and return its value. DO NOT call
85
   tcc_relocate() before. */
6429 siemargl 86
LIBTCCAPI int tcc_run(TCCState *s, int argc, char **argv);
145 halyavin 87
 
6429 siemargl 88
/* do all relocations (needed before using tcc_get_symbol()) */
89
LIBTCCAPI int tcc_relocate(TCCState *s1, void *ptr);
90
/* possible values for 'ptr':
91
   - TCC_RELOCATE_AUTO : Allocate and manage memory internally
92
   - NULL              : return required memory size for the step below
93
   - memory address    : copy code to memory passed by the caller
94
   returns -1 if error. */
95
#define TCC_RELOCATE_AUTO (void*)1
145 halyavin 96
 
6429 siemargl 97
/* return symbol value or NULL if not found */
98
LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name);
145 halyavin 99
 
100
#ifdef __cplusplus
101
}
102
#endif
103
 
104
#endif