Skip to main content
After compilation and linking, you can either run the code in memory or generate an output file.

Memory relocation

tcc_relocate

Performs all relocations needed to run the compiled code in memory. This must be called before using tcc_get_symbol().
TCCState*
required
The compilation context.
int
Returns 0 on success, negative value on error.
Example:
Do not call tcc_relocate() if you’re using tcc_output_file() or tcc_run(). Those functions handle relocation internally.

Running code directly

tcc_run

Compiles, links, and runs the main() function directly. Do not call tcc_relocate() before this.
TCCState*
required
The compilation context.
int
required
Number of command-line arguments to pass to main().
char**
required
Array of command-line arguments.
int
Returns the value returned by the compiled main() function.
Example:

Getting compiled symbols

tcc_get_symbol

Returns a pointer to a symbol (function or variable) from the compiled code. You must call tcc_relocate() first.
TCCState*
required
The compilation context.
const char*
required
Name of the symbol to retrieve.
void*
Pointer to the symbol, or NULL if not found.
Example:

tcc_list_symbols

Lists all global symbols and their values via a callback function.
TCCState*
required
The compilation context.
void*
User data pointer passed to the callback.
void (*)(void*, const char*, const void*)
required
Callback function called for each symbol.
Example:

Advanced execution patterns

Plugin system

Expression evaluator

Hot code reloading

Error handling