source: EcnlProtoTool/trunk/tcc-0.9.26/libtcc.h@ 279

Last change on this file since 279 was 279, checked in by coas-nagasima, 7 years ago

ファイルを追加、更新。

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